From abd87361506a1af72a9eb9878da4d09d3f6397d2 Mon Sep 17 00:00:00 2001 From: "Aurelien van Delft (avd)" Date: Fri, 29 Mar 2024 15:07:11 +0100 Subject: [PATCH] [PERF] mrp: add missing indexes Add missing indexes on stock.move and mrp.workorder to speed up search_read on mrp.production. That's mostly useful at the opening of the Shop Floor app. closes odoo/odoo#160349 Related: odoo/enterprise#59998 Signed-off-by: William Henrotin (whe) --- addons/mrp/models/mrp_workorder.py | 2 +- addons/mrp/models/stock_move.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index e445b40389b..6f3fe4b77c8 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -33,7 +33,7 @@ class MrpWorkorder(models.Model): product_id = fields.Many2one(related='production_id.product_id', readonly=True, store=True, check_company=True) product_tracking = fields.Selection(related="product_id.tracking") product_uom_id = fields.Many2one('uom.uom', 'Unit of Measure', required=True, readonly=True) - production_id = fields.Many2one('mrp.production', 'Manufacturing Order', required=True, check_company=True, readonly=True) + production_id = fields.Many2one('mrp.production', 'Manufacturing Order', required=True, check_company=True, readonly=True, index='btree') production_availability = fields.Selection( string='Stock Availability', readonly=True, related='production_id.reservation_state', store=True) # Technical: used in views and domains only diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index d310ad45e52..f2e82cfcba6 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -135,7 +135,7 @@ class StockMove(models.Model): 'mrp.routing.workcenter', 'Operation To Consume', check_company=True, domain="[('id', 'in', allowed_operation_ids)]") workorder_id = fields.Many2one( - 'mrp.workorder', 'Work Order To Consume', copy=False, check_company=True) + 'mrp.workorder', 'Work Order To Consume', copy=False, check_company=True, index='btree_not_null') # Quantities to process, in normalized UoMs bom_line_id = fields.Many2one('mrp.bom.line', 'BoM Line', check_company=True) byproduct_id = fields.Many2one(