From 36158fe17a5c46314b34e5df95d414834a050dc5 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Mon, 10 Oct 2022 07:51:52 +0000 Subject: [PATCH] [FIX] mrp: force context in computes Computed stored fields should not be depending on context. In this particular case, compute_bom_id will make a 'search' on mrp_bom table with sometimes 'active_test=False' in the context sometimes not. This commit force the context to exclude archive records to ensure we do not set an archived bom on a production order. In a futur versionm it would be nive to have the ORM ignoring the context in such case. closes odoo/odoo#103055 Task: 2991906 X-original-commit: 6274f23a673fe073157d0f975adcb2b0c917b02f Related: odoo/enterprise#32700 Signed-off-by: William Henrotin (whe) --- addons/mrp/models/mrp_production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index e45db5f7572..0ae22adec6e 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -344,7 +344,7 @@ class MrpProduction(models.Model): mo_by_picking_type_and_company_id[(mo.picking_type_id, mo.company_id.id)] |= mo for (picking_type, company_id), productions in mo_by_picking_type_and_company_id.items(): - boms_by_product = self.env['mrp.bom']._bom_find(productions.product_id, picking_type=picking_type, company_id=company_id, bom_type='normal') + boms_by_product = self.env['mrp.bom'].with_context(active_test=True)._bom_find(productions.product_id, picking_type=picking_type, company_id=company_id, bom_type='normal') for production in productions: if not production.bom_id or production.bom_id.product_tmpl_id != production.product_tmpl_id or (production.bom_id.product_id and production.bom_id.product_id != production.product_id): bom = boms_by_product[production.product_id]