[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.
This commit is contained in:
Ronald Portier
2017-02-28 18:42:15 +01:00
committed by Stefan Rijnhart (Opener)
parent 3d2dc86056
commit f1900c6a33
2 changed files with 8 additions and 3 deletions

View File

@@ -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)

View File

@@ -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