From 08518bbad3ffac6a2db3909d26f56be7c4c2c5ec Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 29 Aug 2023 09:01:18 +0200 Subject: [PATCH] [FIX] account: index account codes Account codes are very commonly searched by prefix. This field used to be implicitly indexed thanks to a unique constraint on `(code, company_id)`, however the constraint was removed in #125642 rather than converted to an index. For the issue at hand `code` has a much higher discrimination power than `company_id`, however it might make sense to also index `company_id`, or to add compound indexes for `code, company_id` and / or `company_id, code` for other work loads. X-original-commit: 45c579908d90f6275b7d255d59c6555e8a57b959 Part-of: odoo/odoo#133530 --- addons/account/models/account_account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_account.py b/addons/account/models/account_account.py index 3020e4e843a..8d01c59b0da 100644 --- a/addons/account/models/account_account.py +++ b/addons/account/models/account_account.py @@ -38,7 +38,7 @@ class AccountAccount(models.Model): name = fields.Char(string="Account Name", required=True, index='trigram', tracking=True, translate=True) currency_id = fields.Many2one('res.currency', string='Account Currency', tracking=True, help="Forces all journal items in this account to have a specific currency (i.e. bank journals). If no currency is set, entries can use any currency.") - code = fields.Char(size=64, required=True, tracking=True) + code = fields.Char(size=64, required=True, tracking=True, index=True) deprecated = fields.Boolean(default=False, tracking=True) used = fields.Boolean(compute='_compute_used', search='_search_used') account_type = fields.Selection(