From e01e603cded04a7d86f6f4277fcbd58157a7538f Mon Sep 17 00:00:00 2001 From: hiroh-odoo Date: Tue, 19 Jul 2022 06:57:45 +0000 Subject: [PATCH] [IMP] sale_(project,timesheet): improve generic UX Purpose of this commit is to improve the generic UX of the project and timesheet app. So, in this commit improve the following: - set allocated_hous 0 of task when task is created from SO and SOL product invoice policy in either based on manual or based on milestone - in project.update description improve the following points, - hide the 'activities' heading if there is no activity to display. - hide the 'profitability' sentence if there in no AAL in project's AA. - rename the 'service on timesheet' product into 'service on timesheets'. task-2924215 closes odoo/odoo#96298 Related: odoo/enterprise#29632 Signed-off-by: Laurent Stukkens (ltu) --- addons/sale_project/models/sale_order_line.py | 4 +++- addons/sale_timesheet/data/sale_service_data.xml | 2 +- addons/sale_timesheet/models/project_update.py | 5 +++-- addons/sale_timesheet/views/project_update_templates.xml | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/sale_project/models/sale_order_line.py b/addons/sale_project/models/sale_order_line.py index cb903a5623d..d3a86a1d231 100644 --- a/addons/sale_project/models/sale_order_line.py +++ b/addons/sale_project/models/sale_order_line.py @@ -194,7 +194,9 @@ class SaleOrderLine(models.Model): def _timesheet_create_task_prepare_values(self, project): self.ensure_one() - planned_hours = self._convert_qty_company_hours(self.company_id) + planned_hours = 0.0 + if self.product_id.service_type not in ['milestones', 'manual']: + planned_hours = self._convert_qty_company_hours(self.company_id) sale_line_name_parts = self.name.split('\n') title = sale_line_name_parts[0] or self.product_id.name description = '
'.join(sale_line_name_parts[1:]) diff --git a/addons/sale_timesheet/data/sale_service_data.xml b/addons/sale_timesheet/data/sale_service_data.xml index dbfcea047cc..227bcdb1beb 100644 --- a/addons/sale_timesheet/data/sale_service_data.xml +++ b/addons/sale_timesheet/data/sale_service_data.xml @@ -2,7 +2,7 @@ - Service on Timesheet + Service on Timesheets service 40 diff --git a/addons/sale_timesheet/models/project_update.py b/addons/sale_timesheet/models/project_update.py index 5ac11adeaa1..f54b99b4505 100644 --- a/addons/sale_timesheet/models/project_update.py +++ b/addons/sale_timesheet/models/project_update.py @@ -14,12 +14,13 @@ class ProjectUpdate(models.Model): template_values = super(ProjectUpdate, self)._get_template_values(project) services = self._get_services_values(project) profitability = self._get_profitability_values(project) + show_profitability = bool(profitability and profitability.get('analytic_account_id') and (profitability.get('costs') or profitability.get('revenues'))) show_sold = template_values['project'].allow_billable and len(services.get('data', [])) > 0 return { **template_values, 'show_sold': show_sold, - 'show_profitability': bool(profitability), - 'show_activities': template_values['show_activities'] or show_sold or bool(profitability), + 'show_profitability': show_profitability, + 'show_activities': template_values['show_activities'] or show_profitability or show_sold, 'services': services, 'profitability': profitability, 'format_value': lambda value, is_hour: str(round(value, 2)) if not is_hour else format_duration(value), diff --git a/addons/sale_timesheet/views/project_update_templates.xml b/addons/sale_timesheet/views/project_update_templates.xml index 6f76801ec4e..e6e2f7f1754 100644 --- a/addons/sale_timesheet/views/project_update_templates.xml +++ b/addons/sale_timesheet/views/project_update_templates.xml @@ -35,7 +35,7 @@

Profitability

-The cost of the project is now at , for a revenue of , leading to a + The cost of the project is now at , for a revenue of , leading to a @@ -46,6 +46,7 @@ The cost of the project is now at , margin (%). +