[FIX] mrp: date_planned_start is empty

This commit fixes the traceback when the user push the start button
in the Work Order list View of a work order without a date_planned_start.
To recreate the traceback, the order must be based on a manufacturing order
with multiple work orders, with at least one with a scheduled start date and
one without a scheduled start date.
When creating the manufacturing order, it is important to make sure that
only the confirm button is pressed.

closes odoo/odoo#110587

X-original-commit: c4d16a57e03d2a9183b232344579978b839a9fb9
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
Martin Maes
2023-01-23 11:20:08 +01:00
parent 8d41ccf119
commit 0dab2525f9
+2 -3
View File
@@ -636,10 +636,9 @@ class MrpWorkorder(models.Model):
vals['leave_id'] = leave.id
return self.write(vals)
else:
if self.date_planned_start > start_date:
if not self.date_planned_start or self.date_planned_start > start_date:
vals['date_planned_start'] = start_date
if self.duration_expected:
vals['date_planned_finished'] = self._calculate_date_planned_finished(start_date)
vals['date_planned_finished'] = self._calculate_date_planned_finished(start_date)
if self.date_planned_finished and self.date_planned_finished < start_date:
vals['date_planned_finished'] = start_date
return self.with_context(bypass_duration_calculation=True).write(vals)