Skip to content

Commit

Permalink
[FIX] mrp: write with multiple workorders in self
Browse files Browse the repository at this point in the history
This PR odoo/odoo#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#101580

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
  • Loading branch information
MerlinGuillaume authored and gamarino committed Jan 11, 2023
1 parent 101c12e commit a418b04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions addons/mrp/models/mrp_workorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ def write(self, values):
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:
if 'date_planned_start' in values and 'date_planned_finished' in values:
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 'date_planned_start' in values:
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 'date_planned_finished' in values:
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.
Expand Down

0 comments on commit a418b04

Please sign in to comment.