From eedbcfbef54ac51caf8b732ce5fad71aa30b4cd8 Mon Sep 17 00:00:00 2001 From: fja-odoo Date: Fri, 10 Jul 2020 09:05:50 +0000 Subject: [PATCH] [FIX] mrp: fix _set_qty_producing On a MO which product_id has a serial tracking, some components and 2 or more WO: The method _set_qty_producing of a WO will call the MO _set_qty_producing method even if no changes is made on qty_producing which can produce an undesired aditional move line when creating the MO. On a MO which product_id has a serial tracking and some components: Changing the qty_producing on a MO was adding a line on the component move. Since the _set_qty_producing method is called when creating a WO it sets the qty_producing of the MO to 0. As it does not make sense to have a WO set the qty_producing of a MO to 0 we will not replicate it. task-2278147 closes odoo/odoo#54579 X-original-commit: ca8275aa28010b73cad14f667068e9cfc6c651a5 Related: odoo/enterprise#11896 Signed-off-by: Arnold Moyaux --- addons/mrp/models/mrp_workorder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index d9e89060c5c..96cb3fd5d3e 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -221,8 +221,9 @@ class MrpWorkorder(models.Model): def _set_qty_producing(self): for workorder in self: - workorder.production_id.qty_producing = workorder.qty_producing - workorder.production_id._set_qty_producing() + if workorder.qty_producing != 0 and workorder.production_id.qty_producing != workorder.qty_producing: + workorder.production_id.qty_producing = workorder.qty_producing + workorder.production_id._set_qty_producing() # Both `date_planned_start` and `date_planned_finished` are related fields on `leave_id`. Let's say # we slide a workorder on a gantt view, a single call to write is made with both