From 415aa058069d394355d29bf6c7db6f8aeac95170 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 11 Sep 2018 14:53:54 +0200 Subject: [PATCH] [IMP] account: add error when setting a foreign currency on account If currency set on account, all journal items part of this account must have either the same currency or no currency. --- addons/account/models/account.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index ef611962da9..6ceb5ba19b1 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -167,6 +167,12 @@ class AccountAccount(models.Model): 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')) + + if vals.get('currency_id'): + for account in self: + if self.env['account.move.line'].search_count([('account_id', '=', account.id), ('currency_id', 'not in', (False, vals['currency_id']))]): + raise UserError(_('You cannot set a currency on this account as it already has some journal entries having a different foreign currency.')) + return super(AccountAccount, self).write(vals) @api.multi