From 7f8af8a84bc31620cbec76de12cf600ed9c7396e Mon Sep 17 00:00:00 2001 From: clesgow Date: Thu, 11 May 2023 13:05:17 +0000 Subject: [PATCH] [FIX] mrp: allow override for operation cost in MO Overview Since employees can be assigned directly to a workorder, their hourly cost must be added to the operations cost in the Overview. Those changes allow further override in odoo/enterprise#40953 closes odoo/odoo#123551 X-original-commit: 8802907637b5d862aaa98a1828d29bc7890c53e3 Related: odoo/enterprise#41893 Signed-off-by: William Henrotin (whe) --- addons/mrp/models/mrp_workorder.py | 6 ++++++ addons/mrp/report/mrp_report_mo_overview.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 1fcc9ca6f47..e1bb869fe3c 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -886,3 +886,9 @@ class MrpWorkorder(models.Model): def action_mass_pause(self): for wo in self: wo.button_pending() + + def _compute_expected_operation_cost(self): + return (self.duration_expected / 60.0) * self.workcenter_id.costs_hour + + def _compute_current_operation_cost(self): + return (self.get_duration() / 60.0) * self.workcenter_id.costs_hour diff --git a/addons/mrp/report/mrp_report_mo_overview.py b/addons/mrp/report/mrp_report_mo_overview.py index 726234e4437..ed5963a2eec 100644 --- a/addons/mrp/report/mrp_report_mo_overview.py +++ b/addons/mrp/report/mrp_report_mo_overview.py @@ -124,8 +124,8 @@ class ReportMoOverview(models.AbstractModel): total_current_cost = 0.0 for index, workorder in enumerate(production.workorder_ids): wo_duration = workorder.duration + workorder.get_working_duration() # Add duration of ongoing work sessions. - expected_cost = (workorder.duration_expected / 60.0) * workorder.workcenter_id.costs_hour - current_cost = (wo_duration / 60.0) * workorder.workcenter_id.costs_hour + expected_cost = workorder._compute_expected_operation_cost() + current_cost = workorder._compute_current_operation_cost() operations.append({ 'level': level, 'index': f"{current_index}W{index}",