From d50a840c21f0cf8dad649bca9bb9b9527fa062a9 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Tue, 10 Nov 2020 15:48:08 +0000 Subject: [PATCH] [FIX] mrp: double consuming in backorder operations - Create product FP product to manufacture - Create BoM: - 10 units of FP - Product CP (component) - two operations. - Create MO for FP and plan. - Complete operation 1 for the 10 units - Complete operation 2 for 4 units only - Mark MO as done for 4 units - Click Create Backorder - Check backorder MO Operation 1 is present, marked todo for 6 units, but it was completed for all 10 units. With this commit the quantity todo for the corresponding operation in the backorder is updated to match the qty already produced Removing `qty_producing` as it is computed according to https://github.com/odoo/odoo/blob/ff648a0ace9cf72274211662707e7ee33fc73252/addons/mrp/models/mrp_workorder.py#L50 opw-2374640 closes odoo/odoo#61841 X-original-commit: a32bdf257d7a960fcd96cf6d32443bfe0295a296 Signed-off-by: agr-odoo Signed-off-by: Nicolas Martinelli (nim) --- addons/mrp/models/mrp_production.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index cfd8679ed0b..ab6d498a4a0 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -1389,8 +1389,8 @@ class MrpProduction(models.Model): new_moves_vals.append(move_vals[0]) new_moves = self.env['stock.move'].create(new_moves_vals) backorders |= backorder_mo - for wo in backorder_mo.workorder_ids: - wo.qty_produced = 0 + for old_wo, wo in zip(production.workorder_ids, backorder_mo.workorder_ids): + wo.qty_produced = max(old_wo.qty_produced - old_wo.qty_producing, 0) if wo.product_tracking == 'serial': wo.qty_producing = 1 else: