[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) <whe@odoo.com> Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user