From 0dab2525f9577d7c036bdfa2928e9dece09691a2 Mon Sep 17 00:00:00 2001 From: Martin Maes Date: Wed, 28 Dec 2022 14:12:46 +0000 Subject: [PATCH] [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) --- addons/mrp/models/mrp_workorder.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 239a97725fd..bdb4f89f6d6 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -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)