From a57c23be704b337063b26bc3ac80a1d14cb5dd92 Mon Sep 17 00:00:00 2001 From: JF Aubert Date: Tue, 12 Mar 2024 08:22:06 +0000 Subject: [PATCH] [FIX] mrp: fix start workorder Commit https://github.com/odoo/odoo/pull/110550/commits/b347675c36cc5c3f54bf64f2e295d0afe9196be8 merges mo/wo scheduled & effective dates. Later commit https://github.com/odoo/odoo/pull/128043/commits/62590fa7d742267421a42cbf654352cd5b7e048c for 15.0 fixes the mo start date. Unfortunately, forward ports breaks 16.4 & later: starting a workorder unplan the subsequent ones. closes odoo/odoo#157373 X-original-commit: 36e4a0c5f6b572f27fbfee5c3aa5fe291a6e76c3 Signed-off-by: William Henrotin (whe) Signed-off-by: Jean-Francois Aubert (ajf) --- addons/mrp/models/mrp_workorder.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 04785354ff8..e445b40389b 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -592,11 +592,6 @@ class MrpWorkorder(models.Model): if wo.state in ('done', 'cancel'): continue - if wo.production_id.state != 'progress': - wo.production_id.write({ - 'date_start': fields.Datetime.now() - }) - if wo.product_tracking == 'serial' and wo.qty_producing == 0: wo.qty_producing = 1.0 elif wo.qty_producing == 0: @@ -607,6 +602,11 @@ class MrpWorkorder(models.Model): wo._prepare_timeline_vals(wo.duration, fields.Datetime.now()) ) + if wo.production_id.state != 'progress': + wo.production_id.write({ + 'date_start': fields.Datetime.now() + }) + if wo.state == 'progress': continue date_start = fields.Datetime.now()