Add indexes on account payment models

The fields where the indexes are added are used in searches in
account_payment_order, which becomes really slow when a database have
many lines.
This commit is contained in:
Guewen Baconnier
2019-05-07 11:25:35 +02:00
parent 0edf356c3e
commit 0da899d99f
3 changed files with 8 additions and 3 deletions

View File

@@ -15,7 +15,9 @@ class AccountMoveLine(models.Model):
help='Bank account on which we should pay the supplier')
bank_payment_line_id = fields.Many2one(
'bank.payment.line', string='Bank Payment Line',
readonly=True)
readonly=True,
index=True,
)
payment_line_ids = fields.One2many(
comodel_name='account.payment.line',
inverse_name='move_line_id',

View File

@@ -56,7 +56,9 @@ class AccountPaymentLine(models.Model):
], string='Communication Type', required=True, default='normal')
# v8 field : state
bank_line_id = fields.Many2one(
'bank.payment.line', string='Bank Payment Line', readonly=True)
'bank.payment.line', string='Bank Payment Line', readonly=True,
index=True,
)
_sql_constraints = [(
'name_company_unique',

View File

@@ -11,5 +11,6 @@ class AccountMoveLine(models.Model):
'account.payment.mode',
string='Payment Mode',
domain="[('company_id', '=', company_id)]",
ondelete='restrict'
ondelete='restrict',
index=True,
)