From f1900c6a3300c34e52d5f4ec4a6a9b2130200e89 Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Tue, 28 Feb 2017 18:42:15 +0100 Subject: [PATCH] [FIX] Better message for not determined journal. (#86) * [FIX] Better message for not determined journal. * [FIX] Only check first (and constant) part of message in text. Test on import bank statement checked exception message for wrong journal. Part of message has become variable, so test had to be adapted. --- .../models/account_bank_statement_import.py | 6 +++++- .../tests/test_import_bank_statement.py | 5 +++-- 2 files changed, 8 insertions(+), 3 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 d47bfe8..3fbfbfd 100644 --- a/account_bank_statement_import/models/account_bank_statement_import.py +++ b/account_bank_statement_import/models/account_bank_statement_import.py @@ -150,7 +150,11 @@ class AccountBankStatementImport(models.TransientModel): journal_id = self._get_journal(currency_id, bank_account_id) # By now journal and account_number must be known if not journal_id: - raise UserError(_('Can not determine journal for import.')) + raise UserError( + _('Can not determine journal for import' + ' for account number %s and currency %s.') % + (account_number, currency_code) + ) # Prepare statement data to be used for bank statements creation stmt_vals = self._complete_statement( stmt_vals, journal_id, account_number) diff --git a/account_bank_statement_import/tests/test_import_bank_statement.py b/account_bank_statement_import/tests/test_import_bank_statement.py index 42021ab..bf7b3df 100644 --- a/account_bank_statement_import/tests/test_import_bank_statement.py +++ b/account_bank_statement_import/tests/test_import_bank_statement.py @@ -75,8 +75,9 @@ class TestAccountBankStatementImport(TransactionCase): self.statement_import_model._create_bank_account('123456789') with self.assertRaises(UserError) as e: self.statement_import_model._import_statement(stmt_vals.copy()) - self.assertEqual(e.exception.message, - 'Can not determine journal for import.') + self.assertEqual( + e.exception.message[:25], 'Can not determine journal' + ) def test_create_bank_account(self): """Checks that the bank_account created by the import belongs to the