[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.
This commit is contained in:
Laurent Smet
2018-09-11 16:04:52 +02:00
parent 8781286f1c
commit 415aa05806
+6
View File
@@ -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