From 77c64e3f05bf5389eb918838370c5988e32281be Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert <csn@openerp.com> Date: Tue, 11 Oct 2016 10:56:18 +0200 Subject: [PATCH] [FIX] account: add a constraint to prevent the change of the reconciliation flag on account when there are already account_move_line existing --- addons/account/models/account.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 68b245da1139..7583f7383162 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -160,6 +160,13 @@ class AccountAccount(models.Model): for account in self: if (account.company_id.id <> vals['company_id']) and move_lines: raise UserError(_('You cannot change the owner company of an account that already contains journal items.')) + # If user change the reconcile flag, all aml should be recomputed for that account and this is very costly. + # So to prevent some bugs we add a constraint saying that you cannot change the reconcile field if there is any aml existing + # for that account. + if vals.get('reconcile'): + move_lines = self.env['account.move.line'].search([('account_id', 'in', self.ids)], limit=1) + if len(move_lines): + raise UserError(_('You cannot change the value of the reconciliation on this account as it already has some moves')) return super(AccountAccount, self).write(vals) @api.multi -- GitLab