Merge branch 'IMP-estimate-workload-hide-done-work' into 'main'

[IMP] estimate-workload html file

See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!110
This commit is contained in:
Rémy Taymans 2025-01-31 15:28:30 +00:00
commit a00ee58b62
3 changed files with 109 additions and 90 deletions

View File

@ -0,0 +1 @@
Improve workload analysis file with button to hide done module.

View File

@ -1,4 +1,23 @@
<html> <html>
<head>
<script>
function ShowAll(){
var elements = document.getElementsByClassName('work_done');
for (var i = 0; i < elements.length; i ++) {
elements[i].style.display = 'table-row';
}
}
function HideWorkDone(){
var elements = document.getElementsByClassName('work_done');
for (var i = 0; i < elements.length; i ++) {
elements[i].style.display = 'none';
}
}
</script>
</head>
<body> <body>
<h1>Migration Analysis</h1> <h1>Migration Analysis</h1>
<table border="1" width="100%"> <table border="1" width="100%">
@ -18,6 +37,14 @@
<td>{{ current_date }}</td> <td>{{ current_date }}</td>
</tr> </tr>
</tbody> </tbody>
<tfoot>
<tr>
<td colspan="4" style="text-align: center;">
<a href="#" onclick="ShowAll()">Show All Modules</a>
<a href="#" onclick="HideWorkDone()">Hide Done Modules</a>
</td>
</tr>
</tfoot>
</table> </table>
<h2>Summary</h2> <h2>Summary</h2>
@ -33,29 +60,31 @@
<tr> <tr>
<td>Odoo</td> <td>Odoo</td>
<td>{{ analysis.get_module_qty('odoo') }}</td> <td>{{ analysis.get_module_qty('odoo') }}</td>
<td>{{ analysis.workload_hour_text('odoo') }}</td> <td>{{ time_to_text(analysis.workload('odoo', False)) }}</td>
</tr> </tr>
<tr> <tr>
<td>OCA</td> <td>OCA</td>
<td>{{ analysis.get_module_qty('oca') }}</td> <td>{{ analysis.get_module_qty('oca') }}</td>
<td>{{ analysis.workload_hour_text('oca') }}</td> <td>{{ time_to_text(analysis.workload('oca', False)) }}</td>
</tr> </tr>
<tr> <tr>
<td>Custom</td> <td>Custom</td>
<td>{{ analysis.get_module_qty('custom') }}</td> <td>{{ analysis.get_module_qty('custom') }}</td>
<td>{{ analysis.workload_hour_text('custom') }}</td> <td>{{ time_to_text(analysis.workload('custom', False)) }}</td>
</tr> </tr>
{%- if analysis.get_module_qty('not_found') -%}
<tr> <tr>
<td>Not Found</td> <td>Not Found</td>
<td>{{ analysis.get_module_qty('not_found') }}</td> <td>{{ analysis.get_module_qty('not_found') }}</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
{%- endif -%}
</tbody> </tbody>
<tfood> <tfood>
<tr> <tr>
<th>Total</th> <th>Total</th>
<td>{{ analysis.get_module_qty() }}</td> <td>{{ analysis.get_module_qty() }}</td>
<td>{{ analysis.workload_hour_text() }}</td> <td>{{ time_to_text(analysis.workload(False, False)) }}</td>
</tr> </tr>
</tfood> </tfood>
</table> </table>
@ -66,116 +95,100 @@
<tr> <tr>
<th>&nbsp;</th> <th>&nbsp;</th>
<th>Total</th> <th>Total</th>
{%- for odoo_version in ctx.obj['config']['odoo_versions'] -%} {%- for odoo_version in ctx.obj['config']['odoo_versions'] %}
<th>{{ odoo_version }}</th> <th>{{ odoo_version }}</th>
{% endfor %} {%- endfor %}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% set ns = namespace( {%- set ns = namespace(current_repository='', current_module_type='') %}
current_repository='',
current_module_type='',
) %}
{% for odoo_module in analysis.modules %}
<!-- ---------------------- --> {%- for odoo_module in analysis.modules %}
<!-- Handle New Module Type --> {%- if (ns.current_module_type != odoo_module.module_type) %}
<!-- ---------------------- --> {%- set ns.current_module_type = odoo_module.module_type %}
{% if ( <!-- ------------------------------------------------ -->
ns.current_module_type != odoo_module.module_type <!-- Handle New Module Type {{ns.current_module_type}}-->
and odoo_module.module_type != 'odoo') %} <!-- ------------------------------------------------ -->
{% set ns.current_module_type = odoo_module.module_type %}
<tr> <tr>
<th colspan="{{2 + ctx.obj['config']['odoo_versions']|length}}"> <th colspan="{{2 + ctx.obj['config']['odoo_versions']|length}}">
{{ ns.current_module_type}} <h3>{{ odoo_module.module_type}}</h3>
</th> </th>
<tr> <tr>
{% endif %} {%- endif %}
<!-- -------------------- --> {%- if ns.current_repository != odoo_module.repository %}
<!-- Handle New Repository--> {%- set ns.current_repository = odoo_module.repository %}
<!-- -------------------- --> {%- set repository_workload = analysis.workload(False, odoo_module.repository) %}
{% if ns.current_repository != odoo_module.repository %} <!-- ---------------------------------------------- -->
{% set ns.current_repository = odoo_module.repository %} <!-- Handle New Repository {{ns.current_repository}}-->
<!-- ---------------------------------------------- -->
{% if ns.current_repository %} {%- if ns.current_repository %}
<tr> <tr class="{{repository_workload == 0 and 'work_done' or ''}}">
<th colspan="{{2 + ctx.obj['config']['odoo_versions']|length}}"> <th colspan="{{2 + ctx.obj['config']['odoo_versions']|length}}">
{{ ns.current_repository}} <h4>{{ odoo_module.repository}}
{% if repository_workload %}
({{ time_to_text(repository_workload) }})
{% endif %}
</h4>
</th> </th>
<tr> <tr>
{% endif %} {%- endif %}
{% endif %} {%- endif %}
<!-- -------------------- --> <tr class="{{odoo_module.workload == 0 and 'work_done' or ''}}">
<!-- Display Module Line -->
<!-- -------------------- -->
<tr>
<td>{{odoo_module.name}} <td>{{odoo_module.name}}
{% if odoo_module.module_type == 'not_found' %} {%- if odoo_module.module_type == 'not_found' -%}
{% set odoo_apps_url = odoo_module.get_odoo_apps_url() %} {%- set odoo_apps_url = odoo_module.get_odoo_apps_url() -%}
{% if odoo_apps_url %} {%- if odoo_apps_url -%}
<a href="{{odoo_apps_url}}" target="_blank">AppsStore</a> <a href="{{odoo_apps_url}}" target="_blank">AppsStore</a>
{% else %} {%- else -%}
{% set odoo_code_search_url = odoo_module.get_odoo_code_search_url() %} {%- set odoo_code_search_url = odoo_module.get_odoo_code_search_url() -%}
{% if odoo_code_search_url %} {%- if odoo_code_search_url -%}
<a href="{{odoo_code_search_url}}" target="_blank"> <a href="{{odoo_code_search_url}}" target="_blank">OdooCodeSearch</a>
OdooCodeSearch {%- endif -%}
</a> {%- endif -%}
{% endif %} {%- endif -%}
{% endif %}
{% endif %}
</td> </td>
<td> <td>
{% if odoo_module.workload %} {%- if odoo_module.workload -%}
{{time_to_text(odoo_module.workload)}} {{time_to_text(odoo_module.workload)}}
{% endif %} {%- endif -%}
</td> </td>
{% for version in odoo_module.analyse.all_versions %} {%- for version in odoo_module.analyse.all_versions %}
{% set module_version = odoo_module.get_module_version(version) %} {%- set module_version = odoo_module.get_module_version(version) %}
{% if module_version %} {%- if module_version %}
{% set size_text = module_version.get_size_text() %} {%- set size_text = module_version.get_size_text() %}
{% set analysis_text = module_version.get_analysis_text() %} {%- set analysis_text = module_version.get_analysis_text() %}
{% set workload = module_version.workload %} {%- set workload = module_version.workload %}
<td style="background-color:{{module_version.get_bg_color()}};"> <td style="background-color:{{module_version.get_bg_color()}};">
{{module_version.get_text()}} {{module_version.get_text()}}
{% if workload %} {%- if workload -%}
<span style="background-color:lightblue;"> <span style="background-color:lightblue;">({{time_to_text(workload)}})</span>
({{time_to_text(workload)}}) {%- endif -%}
</span> {%- if size_text -%}
{% endif %} <br/>
{% if size_text %} <span style="color:gray;font-size:11px;font-family:monospace;">({{ size_text}})</span>
{%- endif -%}
{%- if analysis_text -%}
<br/> <br/>
<span style="color:gray;font-size:11px;font-family:monospace;"> <span style="color:gray;font-size:11px;font-family:monospace;">
({{ size_text}}) <a href="{{module_version.analysis_url()}}" target="_blank">({{ analysis_text}})</a>
</span> </span>
{% endif %} {%- endif %}
{% if analysis_text %}
<br/>
<span style="color:gray;font-size:11px;font-family:monospace;">
<a href="{{module_version.analysis_url()}}" target="_blank">
({{ analysis_text}})
</a>
</span>
{% endif %}
</td> </td>
{% else %} {%- else %}
<td style="background-color:gray;">&nbsp;</td> <td style="background-color:gray;">&nbsp;</td>
{% endif %} {%- endif %}
{% endfor %} {%- endfor %}
</tr> </tr>
{%- endfor %}
{% endfor %}
</tbody> </tbody>
</table> </table>

View File

@ -291,22 +291,27 @@ class Analysis(object):
odoo_modules = self.modules odoo_modules = self.modules
return len(odoo_modules) return len(odoo_modules)
def workload_hour_text(self, module_type=False): def workload(self, module_type, repository):
odoo_modules = self.modules
if module_type: if module_type:
odoo_modules = [ odoo_modules = [
x x
for x in filter( for x in filter(
lambda x: x.module_type == module_type, self.modules lambda x: x.module_type == module_type, odoo_modules
)
]
if repository:
odoo_modules = [
x
for x in filter(
lambda x: x.repository == repository, odoo_modules
) )
] ]
else:
odoo_modules = self.modules
total = 0 total = 0
for odoo_module in odoo_modules: for odoo_module in odoo_modules:
for module_version in list(odoo_module.module_versions.values()): for module_version in list(odoo_module.module_versions.values()):
total += module_version.workload total += module_version.workload
return "%d h" % (int(round(total / 60))) return total
@total_ordering @total_ordering