[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 <amoyaux@users.noreply.github.com>
This commit is contained in:
fja-odoo
2020-07-16 13:02:14 +00:00
committed by Arnold Moyaux
parent 8a8d5eba09
commit eedbcfbef5
+3 -2
View File
@@ -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