From fe918d40b140cf030b768e2bc0a757927df3ca2a Mon Sep 17 00:00:00 2001 From: Brice bib Bartoletti Date: Mon, 9 May 2022 07:36:31 +0000 Subject: [PATCH] [IMP] account: faster account_move unlink MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- addons/account/models/account_move.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 7cddac9421e..56ac0b9af69 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -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') # =========================================================