[IMP] account: faster account_move unlink

On huge DB, unlinking an account_move can take a lot of time.
Most of this time is wasted checking for foreign key constraint.

closes odoo/odoo#84817

Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
Brice bib Bartoletti
2022-05-09 11:25:21 +02:00
parent b9f4fff0b5
commit fe918d40b1
+8 -2
View File
@@ -297,8 +297,14 @@ class AccountMove(models.Model):
help='If this checkbox is ticked, this entry will be automatically posted at its date.')
# ==== Reverse feature fields ====
reversed_entry_id = fields.Many2one('account.move', string="Reversal of", readonly=True, copy=False,
check_company=True)
reversed_entry_id = fields.Many2one(
comodel_name='account.move',
string="Reversal of",
index='btree_not_null',
readonly=True,
copy=False,
check_company=True
)
reversal_move_id = fields.One2many('account.move', 'reversed_entry_id')
# =========================================================