[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
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user