[FIX] mrp: optimize _compute_used_in_bom_count
previous implementation works slowly for products with many variants. Performance Test ================ * ~5 K product.template * ~14 K product.variants * ~12 K mrp.bom * ~414 K mrp.bom.line Reading time for the field on a product with ~1000 variants Measuring total request time: * Before 9,5 sec * After: ** without module upgrade 1,5 sec ** with module upgrade 0,3 sec Measuring query execution in psql: * Before 7,2 sec * After: ** without module upgrade 0,7 sec ** with module upgrade 0,001 sec --- opw-2494423 closes odoo/odoo#69293 Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
This commit is contained in:
@@ -288,7 +288,7 @@ class MrpBomLine(models.Model):
|
||||
return self.env['uom.uom'].search([], limit=1, order='id').id
|
||||
|
||||
product_id = fields.Many2one('product.product', 'Component', required=True, check_company=True)
|
||||
product_tmpl_id = fields.Many2one('product.template', 'Product Template', related='product_id.product_tmpl_id')
|
||||
product_tmpl_id = fields.Many2one('product.template', 'Product Template', related='product_id.product_tmpl_id', store=True, index=True)
|
||||
company_id = fields.Many2one(
|
||||
related='bom_id.company_id', store=True, index=True, readonly=True)
|
||||
product_qty = fields.Float(
|
||||
|
||||
Reference in New Issue
Block a user