From 6e01dd43caeb53ac4939133ce6b9d30a242c358c Mon Sep 17 00:00:00 2001 From: Ravi Patel Date: Thu, 7 Jul 2016 16:36:20 +0530 Subject: [PATCH] [IMP] account: Don't raise errors if account currency = base currency Steps to Reproduce: - Company set in USD - Customer Invoices journal set in USD - Related account set in USD - Create an invoice, validate It raises an error: "The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account." The error should be raised if the currencies are different. It should be transparent to the user if the currencies are the same. It should raise an error when: - The journal currency' and Currency of Accounts Selected on Journal are different - The journal currency is blank (by default company currency) and the account currency is other than company currency + Some wording improvements --- addons/account/models/account.py | 2 +- addons/account/models/account_move.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index eb0b26b6963..ac1dab1c0bf 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -97,7 +97,7 @@ class AccountAccount(models.Model): name = fields.Char(required=True, index=True) currency_id = fields.Many2one('res.currency', string='Account Currency', - help="Forces all moves for this account to have this account currency.") + help="Forces all moves for this account to have this secondary currency.") code = fields.Char(size=64, required=True, index=True) deprecated = fields.Boolean(index=True, default=False) user_type_id = fields.Many2one('account.account.type', string='Type', required=True, oldname="user_type", diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 2b82cef6c85..b59ac8831aa 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -410,8 +410,8 @@ class AccountMoveLine(models.Model): def _check_currency(self): for line in self: if line.account_id.currency_id: - if not line.currency_id or line.currency_id.id != line.account_id.currency_id.id: - raise ValidationError(_('The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account.')) + if not line.journal_id.currency_id and line.company_id.currency_id.id != line.account_id.currency_id.id or line.journal_id.currency_id.id != line.account_id.currency_id.id: + raise ValidationError(_('The selected account of your Journal Entry force to provide a secondary currency. You should either remove the secondary currency on the account or match the currency of your journal with your account currency.')) @api.multi @api.constrains('currency_id', 'amount_currency')