diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 68b245da1139c9c3c94f780a5dd1cebe0bd0d4fd..7583f7383162834e598859a53c744643d14a7c48 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