From b3fedb4df75570f72354b45e0ff5ec53ab87faa7 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 13 Jan 2016 00:05:53 +0100 Subject: [PATCH] Better error message --- .../models/account_bank_statement_import.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/account_bank_statement_import/models/account_bank_statement_import.py b/account_bank_statement_import/models/account_bank_statement_import.py index 0c4399c..ddb7eef 100644 --- a/account_bank_statement_import/models/account_bank_statement_import.py +++ b/account_bank_statement_import/models/account_bank_statement_import.py @@ -238,6 +238,7 @@ class AccountBankStatementImport(models.TransientModel): bank_model = self.env['res.partner.bank'] # Find the journal from context, wizard or bank account journal_id = self.env.context.get('journal_id') or self.journal_id.id + currency = self.env['res.currency'].browse(currency_id) if bank_account_id: bank_account = bank_model.browse(bank_account_id) if journal_id: @@ -267,23 +268,26 @@ class AccountBankStatementImport(models.TransientModel): journal_currency_id ) raise UserError(_( - 'The currency of the bank statement is not ' - 'the same as the currency of the journal !' - )) + 'The currency of the bank statement (%s) is not ' + 'the same as the currency of the journal %s (%s) !' + ) % ( + currency.name, + journal_obj.name, + journal_obj.currency.name)) else: - company_currency_id = self.env.user.company_id.currency_id.id - if currency_id != company_currency_id: + company_currency = self.env.user.company_id.currency_id + if currency_id != company_currency.id: # ALso log message with id's for technical analysis: _logger.warn( _('Statement currency id is %d,' ' but company currency id = %d.'), currency_id, - company_currency_id + company_currency.id ) raise UserError(_( - 'The currency of the bank statement is not ' - 'the same as the company currency !' - )) + 'The currency of the bank statement (%s) is not ' + 'the same as the company currency (%s) !' + ) % (currency.name, company_currency.name)) return journal_id @api.model