mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
Better error message
This commit is contained in:
@@ -238,6 +238,7 @@ class AccountBankStatementImport(models.TransientModel):
|
|||||||
bank_model = self.env['res.partner.bank']
|
bank_model = self.env['res.partner.bank']
|
||||||
# Find the journal from context, wizard or bank account
|
# Find the journal from context, wizard or bank account
|
||||||
journal_id = self.env.context.get('journal_id') or self.journal_id.id
|
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:
|
if bank_account_id:
|
||||||
bank_account = bank_model.browse(bank_account_id)
|
bank_account = bank_model.browse(bank_account_id)
|
||||||
if journal_id:
|
if journal_id:
|
||||||
@@ -267,23 +268,26 @@ class AccountBankStatementImport(models.TransientModel):
|
|||||||
journal_currency_id
|
journal_currency_id
|
||||||
)
|
)
|
||||||
raise UserError(_(
|
raise UserError(_(
|
||||||
'The currency of the bank statement is not '
|
'The currency of the bank statement (%s) is not '
|
||||||
'the same as the currency of the journal !'
|
'the same as the currency of the journal %s (%s) !'
|
||||||
))
|
) % (
|
||||||
|
currency.name,
|
||||||
|
journal_obj.name,
|
||||||
|
journal_obj.currency.name))
|
||||||
else:
|
else:
|
||||||
company_currency_id = self.env.user.company_id.currency_id.id
|
company_currency = self.env.user.company_id.currency_id
|
||||||
if currency_id != company_currency_id:
|
if currency_id != company_currency.id:
|
||||||
# ALso log message with id's for technical analysis:
|
# ALso log message with id's for technical analysis:
|
||||||
_logger.warn(
|
_logger.warn(
|
||||||
_('Statement currency id is %d,'
|
_('Statement currency id is %d,'
|
||||||
' but company currency id = %d.'),
|
' but company currency id = %d.'),
|
||||||
currency_id,
|
currency_id,
|
||||||
company_currency_id
|
company_currency.id
|
||||||
)
|
)
|
||||||
raise UserError(_(
|
raise UserError(_(
|
||||||
'The currency of the bank statement is not '
|
'The currency of the bank statement (%s) is not '
|
||||||
'the same as the company currency !'
|
'the same as the company currency (%s) !'
|
||||||
))
|
) % (currency.name, company_currency.name))
|
||||||
return journal_id
|
return journal_id
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|||||||
Reference in New Issue
Block a user