From 849856843aeab04cd6dc562ca34142a5db6b7e90 Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Thu, 29 Sep 2022 11:05:46 +0000 Subject: [PATCH] [FIX] mrp: write with multiple workorders in self This PR https://github.com/odoo/odoo/pull/97805 wrongly assumed that self contained a single workorder. This would raise an error if there were multiple records in self. Solution: Modify calls on `self` to `workorder` (as we already iterate through them) closes odoo/odoo#101775 X-original-commit: 26cb902e603d6d576957d1d329d3eef4e76af5f8 Signed-off-by: William Henrotin (whe) Signed-off-by: Guillaume Merlin (megu) --- addons/mrp/models/mrp_workorder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index ff9a7979737..f22a39c9af1 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -454,13 +454,13 @@ class MrpWorkorder(models.Model): raise UserError(_('The planned end date of the work order cannot be prior to the planned start date, please correct this to save the work order.')) if 'duration_expected' not in values and not self.env.context.get('bypass_duration_calculation'): if values.get('date_planned_start') and values.get('date_planned_finished'): - computed_finished_time = self._calculate_date_planned_finished(start_date) + computed_finished_time = workorder._calculate_date_planned_finished(start_date) values['date_planned_finished'] = computed_finished_time elif values.get('date_planned_start'): - computed_duration = self._calculate_duration_expected(date_planned_start=start_date) + computed_duration = workorder._calculate_duration_expected(date_planned_start=start_date) values['duration_expected'] = computed_duration elif values.get('date_planned_finished'): - computed_duration = self._calculate_duration_expected(date_planned_finished=end_date) + computed_duration = workorder._calculate_duration_expected(date_planned_finished=end_date) values['duration_expected'] = computed_duration # Update MO dates if the start date of the first WO or the # finished date of the last WO is update.