From 22f0da809e84618901b7ca4b78582abd64c03c55 Mon Sep 17 00:00:00 2001 From: Olivier Colson Date: Fri, 19 Oct 2018 15:04:12 +0200 Subject: [PATCH] [IMP] account: Trigger a validation error when trying to set the same currency on a journal as on its parent company. Until v12, doing this is wrong. The currency_id field of account.journal should only be used if the journal is in a different currency. Otherwise, this field should stay empty. //NOTE FOR FORWARD-PORT: this commit should not be ported to 12.0 and further. --- addons/account/i18n/account.pot | 5 +++++ addons/account/models/account.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 8b3c1c4f6cc..657f2638631 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -10051,3 +10051,8 @@ msgstr "" msgid "→ Count" msgstr "" +#. module: account +#: code:addons/account/models/account.py:309 +#, python-format +msgid "Currency field should only be set if the journal's currency is different from the company's. Leave the field blank to use company currency." +msgstr "" diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 1eedaf8437c..f8f1303277c 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -305,6 +305,8 @@ class AccountJournal(models.Model): @api.constrains('currency_id', 'default_credit_account_id', 'default_debit_account_id') def _check_currency(self): if self.currency_id: + if self.currency_id == self.company_id.currency_id: + raise ValidationError(_("Currency field should only be set if the journal's currency is different from the company's. Leave the field blank to use company currency.")) if self.default_credit_account_id and not self.default_credit_account_id.currency_id.id == self.currency_id.id: raise ValidationError(_('Configuration error!\nThe currency of the journal should be the same than the default credit account.')) if self.default_debit_account_id and not self.default_debit_account_id.currency_id.id == self.currency_id.id: