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 631188dcba..77f4e46440 100644 --- a/account_bank_statement_import/tests/test_import_bank_statement.py +++ b/account_bank_statement_import/tests/test_import_bank_statement.py @@ -65,16 +65,23 @@ def test_import_preconditions(self): * no bank account found for the account_number * no account_journal found on the bank_account """ + import_model = self.env['account.bank.statement.import'] stmt_vals = { 'currency_code': 'EUR', - 'account_number': '123456789'} + 'account_number': '123456789', + } with self.assertRaises(UserError) as e: - self.statement_import_model._import_statement(stmt_vals.copy()) - self.assertEqual(e.exception.message, - 'Can not find the account number 123456789.') - self.statement_import_model._create_bank_account('123456789') + import_model._import_statement(stmt_vals.copy()) + self.assertEqual( + e.exception.message, + 'Can not find the account number 123456789.' + ) + new_bank = import_model._create_bank_account('123456789') + # Need company_id on bank, otherwise we will not even reach + # the check for the journal_id: + new_bank.write({'company_id': self.env.user.company_id.id}) with self.assertRaises(UserError) as e: - self.statement_import_model._import_statement(stmt_vals.copy()) + import_model._import_statement(stmt_vals.copy()) self.assertEqual( e.exception.message[:25], 'Can not determine journal' )