From 58f80b60bf9d789f5c0c2a8ac0a786bac3f59139 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 22 May 2020 13:29:49 +0000 Subject: [PATCH] [FIX] mrp: BOM in wrong company - Create 2 companies C1 & C2 - Creae a product P - In C1, set the routes as MTO + Buy, add a supplier - In C2, add a BOM in kit for P - Go back to C1 with C2 as an allowed company - Create a SO for 1 unit of P, confirm The PO for P is not created. It occurs because the BOM of C2 is retrieved when running the procurement, while it shouldn't be. opw-2260945 closes odoo/odoo#51779 X-original-commit: 96b0dcf9e51f5a924e2cbf618c2ee5462cc1f03f Signed-off-by: Arnold Moyaux Signed-off-by: Nicolas Martinelli (nim) --- addons/mrp/models/stock_rule.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/mrp/models/stock_rule.py b/addons/mrp/models/stock_rule.py index 2433f3f21b1..a7dfd5e8961 100644 --- a/addons/mrp/models/stock_rule.py +++ b/addons/mrp/models/stock_rule.py @@ -149,7 +149,11 @@ class ProcurementGroup(models.Model): """ procurements_without_kit = [] for procurement in procurements: - bom_kit = self.env['mrp.bom']._bom_find(product=procurement.product_id, bom_type='phantom') + bom_kit = self.env['mrp.bom']._bom_find( + product=procurement.product_id, + company_id=procurement.company_id.id, + bom_type='phantom', + ) if bom_kit: order_qty = procurement.product_uom._compute_quantity(procurement.product_qty, bom_kit.product_uom_id, round=False) qty_to_produce = (order_qty / bom_kit.product_qty)