[IMP] estimate_workload: add time configuration
This commit is contained in:
parent
a2423ec4f8
commit
312e654e88
|
|
@ -26,11 +26,40 @@ from odoo_openupgrade_wizard.tools.tools_system import (
|
|||
" file will be used to define the list of module to analyse."
|
||||
"Ex: 'account,product,base'",
|
||||
)
|
||||
@click.option(
|
||||
"--time-unit",
|
||||
type=click.Choice(["hour", "minute", "separator"]),
|
||||
default="separator",
|
||||
show_default=True,
|
||||
help="Select unit to display time in the report. "
|
||||
"*separator* display time as `HHH<sep>MM`, "
|
||||
"*hour* display time as decimal hour, "
|
||||
"*min* display time as minute (rounded).",
|
||||
)
|
||||
@click.option(
|
||||
"--time-separator",
|
||||
default=":",
|
||||
help="Specify time separator, if time-unit is separator. "
|
||||
"Default to `:` (it will produce time like this HHH:MM).",
|
||||
)
|
||||
@click.pass_context
|
||||
def estimate_workload(ctx, analysis_file_path, extra_modules_list):
|
||||
def estimate_workload(
|
||||
ctx, analysis_file_path, extra_modules_list, time_unit, time_separator
|
||||
):
|
||||
# Analyse
|
||||
analysis = Analysis(ctx)
|
||||
|
||||
def time_to_text(minutes):
|
||||
"""Return a text representation for minutes"""
|
||||
hours, mins = divmod(minutes, 60)
|
||||
if time_unit == "hour":
|
||||
result = str(hours)
|
||||
elif time_unit == "minute":
|
||||
result = str(minutes)
|
||||
else:
|
||||
result = "{}{}{:02d}".format(hours, time_separator, mins)
|
||||
return result
|
||||
|
||||
if extra_modules_list:
|
||||
module_list = extra_modules_list.split(",")
|
||||
else:
|
||||
|
|
@ -51,4 +80,5 @@ def estimate_workload(ctx, analysis_file_path, extra_modules_list):
|
|||
ctx=ctx,
|
||||
analysis=analysis,
|
||||
current_date=datetime.now().strftime("%d/%m/%Y %H:%M:%S"),
|
||||
time_to_text=time_to_text,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Estimated time (min)</th>
|
||||
<th>Total</th>
|
||||
{%- for odoo_version in ctx.obj['config']['odoo_versions'] -%}
|
||||
<th>{{ odoo_version }}</th>
|
||||
{% endfor %}
|
||||
|
|
@ -132,7 +132,11 @@
|
|||
|
||||
</td>
|
||||
|
||||
<td>{{odoo_module.workload}}</td>
|
||||
<td>
|
||||
{% if odoo_module.workload %}
|
||||
{{time_to_text(odoo_module.workload)}}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
{% for version in odoo_module.analyse.all_versions %}
|
||||
{% set module_version = odoo_module.get_module_version(version) %}
|
||||
|
|
@ -146,7 +150,7 @@
|
|||
|
||||
{% if workload %}
|
||||
<span style="background-color:lightblue;">
|
||||
({{ module_version.workload_hour_text()}})
|
||||
({{time_to_text(workload)}})
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if size_text %}
|
||||
|
|
|
|||
|
|
@ -500,12 +500,20 @@ class OdooModuleVersion(object):
|
|||
self.python_code = 0
|
||||
self.xml_code = 0
|
||||
self.javascript_code = 0
|
||||
self.workload = 0
|
||||
self._workload = 0
|
||||
self.analysis_file = False
|
||||
self.openupgrade_model_lines = 0
|
||||
self.openupgrade_field_lines = 0
|
||||
self.openupgrade_xml_lines = 0
|
||||
|
||||
@property
|
||||
def workload(self):
|
||||
return int(round(self._workload))
|
||||
|
||||
@workload.setter
|
||||
def workload(self, value):
|
||||
self._workload = int(round(value))
|
||||
|
||||
def get_last_existing_version(self):
|
||||
if self.odoo_module.module_type != "not_found":
|
||||
versions = list(self.odoo_module.module_versions.values())
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user