From 07b1aa537630eb152198e470c4fd23ba274922bb Mon Sep 17 00:00:00 2001 From: JordiMForgeFlow Date: Wed, 30 Nov 2022 14:48:29 +0000 Subject: [PATCH] [FIX] purchase_mrp: filter cancelled moves when evaluating kit The current behaviour does not filter the cancelled moves when evaluating if the product of the purchase order line is a kit. This causes that, in cases where you have a cancelled wrong receipt where the product was being received as a kit, if a new receipt is created without receiving as a kit Odoo will always expect it as a kit. After the fix, the cancelled moves will not be considered, as this is what should be expected from cancelled operations. closes odoo/odoo#107144 X-original-commit: 9659683d1f09c49a3ba3df8770eb7256660d0033 Signed-off-by: William Henrotin (whe) --- addons/purchase_mrp/models/purchase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase_mrp/models/purchase.py b/addons/purchase_mrp/models/purchase.py index 43dd5d7c679..38c61c0f81d 100644 --- a/addons/purchase_mrp/models/purchase.py +++ b/addons/purchase_mrp/models/purchase.py @@ -49,7 +49,7 @@ class PurchaseOrderLine(models.Model): def _compute_qty_received(self): kit_lines = self.env['purchase.order.line'] - lines_stock = self.filtered(lambda l: l.qty_received_method == 'stock_moves' and l.move_ids) + lines_stock = self.filtered(lambda l: l.qty_received_method == 'stock_moves' and l.move_ids and l.state != 'cancel') product_by_company = defaultdict(OrderedSet) for line in lines_stock: product_by_company[line.company_id].add(line.product_id.id)