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>
<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>
<h1>Migration Analysis</h1>
<table border="1" width="100%">
@ -18,6 +37,14 @@
<td>{{ current_date }}</td>
</tr>
</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>
<h2>Summary</h2>
@ -33,29 +60,31 @@
<tr>
<td>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>
<td>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>
<td>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>
{%- if analysis.get_module_qty('not_found') -%}
<tr>
<td>Not Found</td>
<td>{{ analysis.get_module_qty('not_found') }}</td>
<td>&nbsp;</td>
</tr>
{%- endif -%}
</tbody>
<tfood>
<tr>
<th>Total</th>
<td>{{ analysis.get_module_qty() }}</td>
<td>{{ analysis.workload_hour_text() }}</td>
<td>{{ time_to_text(analysis.workload(False, False)) }}</td>
</tr>
</tfood>
</table>
@ -66,116 +95,100 @@
<tr>
<th>&nbsp;</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>
{% endfor %}
{%- endfor %}
</tr>
</thead>
<tbody>
{% set ns = namespace(
current_repository='',
current_module_type='',
) %}
{% for odoo_module in analysis.modules %}
{%- set ns = namespace(current_repository='', current_module_type='') %}
<!-- ---------------------- -->
<!-- Handle New Module Type -->
<!-- ---------------------- -->
{%- for odoo_module in analysis.modules %}
{%- 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
and odoo_module.module_type != 'odoo') %}
{% set ns.current_module_type = odoo_module.module_type %}
<!-- ------------------------------------------------ -->
<!-- Handle New Module Type {{ns.current_module_type}}-->
<!-- ------------------------------------------------ -->
<tr>
<th colspan="{{2 + ctx.obj['config']['odoo_versions']|length}}">
{{ ns.current_module_type}}
<h3>{{ odoo_module.module_type}}</h3>
</th>
<tr>
{% endif %}
{%- endif %}
<!-- -------------------- -->
<!-- Handle New Repository-->
<!-- -------------------- -->
{%- if ns.current_repository != odoo_module.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 %}
<tr>
{%- if ns.current_repository %}
<tr class="{{repository_workload == 0 and 'work_done' or ''}}">
<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>
<tr>
{% endif %}
{% endif %}
{%- endif %}
{%- endif %}
<!-- -------------------- -->
<!-- Display Module Line -->
<!-- -------------------- -->
<tr>
<tr class="{{odoo_module.workload == 0 and 'work_done' or ''}}">
<td>{{odoo_module.name}}
{% if odoo_module.module_type == 'not_found' %}
{% set odoo_apps_url = odoo_module.get_odoo_apps_url() %}
{% if odoo_apps_url %}
<a href="{{odoo_apps_url}}" target="_blank">AppsStore</a>
{% else %}
{% set odoo_code_search_url = odoo_module.get_odoo_code_search_url() %}
{% if odoo_code_search_url %}
<a href="{{odoo_code_search_url}}" target="_blank">
OdooCodeSearch
</a>
{% endif %}
{% endif %}
{% endif %}
{%- if odoo_module.module_type == 'not_found' -%}
{%- set odoo_apps_url = odoo_module.get_odoo_apps_url() -%}
{%- if odoo_apps_url -%}
<a href="{{odoo_apps_url}}" target="_blank">AppsStore</a>
{%- else -%}
{%- set odoo_code_search_url = odoo_module.get_odoo_code_search_url() -%}
{%- if odoo_code_search_url -%}
<a href="{{odoo_code_search_url}}" target="_blank">OdooCodeSearch</a>
{%- endif -%}
{%- endif -%}
{%- endif -%}
</td>
<td>
{% if odoo_module.workload %}
{%- if odoo_module.workload -%}
{{time_to_text(odoo_module.workload)}}
{% endif %}
{%- endif -%}
</td>
{% for version in odoo_module.analyse.all_versions %}
{% set module_version = odoo_module.get_module_version(version) %}
{% if module_version %}
{% set size_text = module_version.get_size_text() %}
{% set analysis_text = module_version.get_analysis_text() %}
{% set workload = module_version.workload %}
{%- for version in odoo_module.analyse.all_versions %}
{%- set module_version = odoo_module.get_module_version(version) %}
{%- if module_version %}
{%- set size_text = module_version.get_size_text() %}
{%- set analysis_text = module_version.get_analysis_text() %}
{%- set workload = module_version.workload %}
<td style="background-color:{{module_version.get_bg_color()}};">
{{module_version.get_text()}}
{% if workload %}
<span style="background-color:lightblue;">
({{time_to_text(workload)}})
</span>
{% endif %}
{% if size_text %}
<br/>
<span style="color:gray;font-size:11px;font-family:monospace;">
({{ size_text}})
</span>
{% 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 %}
{%- if workload -%}
<span style="background-color:lightblue;">({{time_to_text(workload)}})</span>
{%- endif -%}
{%- if size_text -%}
<br/>
<span style="color:gray;font-size:11px;font-family:monospace;">({{ size_text}})</span>
{%- 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>
{% else %}
{%- else %}
<td style="background-color:gray;">&nbsp;</td>
{% endif %}
{% endfor %}
{%- endif %}
{%- endfor %}
</tr>
{% endfor %}
{%- endfor %}
</tbody>
</table>

View File

@ -291,22 +291,27 @@ class Analysis(object):
odoo_modules = self.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:
odoo_modules = [
x
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
for odoo_module in odoo_modules:
for module_version in list(odoo_module.module_versions.values()):
total += module_version.workload
return "%d h" % (int(round(total / 60)))
return total
@total_ordering