From 24adcfe43eae856381f439e6ac45ac14c9d074ef Mon Sep 17 00:00:00 2001 From: william-andre Date: Mon, 24 Oct 2022 14:09:04 +0000 Subject: [PATCH] [FIX] account: add index on company_id on account.move{,.line} The company is very often used in the queries because of the record rules (i.e. `account.account_move_comp_rule`). Adding the index can help improve queries coming from multiple places. closes odoo/odoo#104066 X-original-commit: b2f620c59861e76443364f5bab6cade7c8eeca93 Signed-off-by: Nicolas Viseur (vin) --- addons/account/models/account_move.py | 1 + addons/account/models/account_move_line.py | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 926f8f3d1be..1dff5c389c8 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -137,6 +137,7 @@ class AccountMove(models.Model): comodel_name='res.company', string='Company', compute='_compute_company_id', inverse='_inverse_company_id', store=True, readonly=False, precompute=True, + index=True, ) line_ids = fields.One2many( 'account.move.line', diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index af846332f2b..5be175cbf0f 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -43,6 +43,7 @@ class AccountMoveLine(models.Model): ) company_id = fields.Many2one( related='move_id.company_id', store=True, readonly=True, precompute=True, + index=True, ) company_currency_id = fields.Many2one( string='Company Currency',