From cbeaf6ffd4fd471c8b91d8cfa6d96c141a006997 Mon Sep 17 00:00:00 2001 From: "Eteil Djoumatchoua(etdj)" Date: Tue, 21 Mar 2023 11:52:31 +0000 Subject: [PATCH] [FIX] mrp: Allow to ajust real duration on workorder operation Steps: - Enable `Worder orders` in Manufacturing settings - Create a manufacturing order with a bill of materials and workorder operation set and confirm - Go to the workorder tab and start, then finish after few seconds - Update the real duration - Try to save Issue: User Error Cause: When writing on a `mrp.production` object we check if the production is still planned and if, it try to plan all the workorders which are not done or cancelled. But in our case all the workorders are done so it try to write to an empty object. opw-3230310 closes odoo/odoo#116122 X-original-commit: 674f37fbbaa4a0d7f34f8d75d16dd11373815932 Signed-off-by: William Henrotin (whe) Signed-off-by: Djoumatchoua Eteil Junior (etdj) --- addons/mrp/models/mrp_production.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index cddccb861a6..4e2e5f6608c 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -1307,6 +1307,9 @@ class MrpProduction(models.Model): workorder._plan_workorder(replan) workorders = self.workorder_ids.filtered(lambda w: w.state not in ['done', 'cancel']) + if not workorders: + return + self.with_context(force_date=True).write({ 'date_start': min([workorder.leave_id.date_from for workorder in workorders]), 'date_finished': max([workorder.leave_id.date_to for workorder in workorders])