[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) <whe@odoo.com>
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user