[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) <vin@odoo.com>
This commit is contained in:
william-andre
2022-10-25 15:03:43 +02:00
parent f7356f6a19
commit 24adcfe43e
2 changed files with 2 additions and 0 deletions
+1
View File
@@ -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',
@@ -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',