From ed3f448e682a1fec032a52f9090ded5fdffa948a Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 3 Mar 2020 07:53:21 +0000 Subject: [PATCH] [FIX] purchase_stock: deliver qui with different UoM - Create a product A with UoM set to 'Units(s)' - Create a product B with UoM set to 'Liter(s)' - Create a BOM of type kit, 2 Liters of B to create 1 Unit of A - Create a PO with A, validate - Validate the corresponding picking An error is raised since we try to compute the quantity received in Units based on a quantity in Liters. In case of a kit BOM, an override exists in `purchase_mrp` to compute correctly the quantity. Therefore, we can skip the line. Corresponding fix for SO: 47959438b6c106e6c9f2f8d849439edf370f390c Closes #45871 opw-2205970 closes odoo/odoo#46748 X-original-commit: 2ad4621c03a1885f2bb210960ebe8b5ae277e439 Signed-off-by: Nicolas Martinelli (nim) --- addons/purchase_stock/models/purchase.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index a3db07965a6..18222c3e8b5 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -255,7 +255,9 @@ class PurchaseOrderLine(models.Model): for line in self: if line.qty_received_method == 'stock_moves': total = 0.0 - for move in line.move_ids: + # In case of a BOM in kit, the products delivered do not correspond to the products in + # the PO. Therefore, we can skip them since they will be handled later on. + for move in line.move_ids.filtered(lambda m: m.product_id == line.product_id): if move.state == 'done': if move.location_dest_id.usage == "supplier": if move.to_refund: