[FIX] Import exceptions.Warning as UserError.

This according to OCA guidelines.
Also reformat README.rst to keep lines within limit.
This commit is contained in:
Ronald Portier (Therp BV)
2015-10-02 00:12:32 +02:00
parent f5f892ffa9
commit 7d12ce19f1
18 changed files with 82 additions and 67 deletions

View File

@@ -2,14 +2,14 @@
{
'name': 'Account Bank Statement Import',
'category': 'Banking addons',
'version': '8.0.1.0.1',
'version': '8.0.1.0.2',
'license': 'AGPL-3',
'author': 'OpenERP SA,'
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/bank-statement-import',
'depends': ['account'],
'data': [
"views/account_config_settings.xml",
'views/account_config_settings.xml',
'views/account_bank_statement_import_view.xml',
],
'demo': [

View File

@@ -144,8 +144,9 @@ class AccountBankStatementImport(models.TransientModel):
currency_id = self._find_currency_id(currency_code)
bank_account_id = self._find_bank_account_id(account_number)
if not bank_account_id and account_number:
raise Warning(_('Can not find the account number %s.') %
account_number)
raise UserError(
_('Can not find the account number %s.') % account_number
)
# Find the bank journal
journal_id = self._get_journal(currency_id, bank_account_id)
# By now journal and account_number must be known

View File

@@ -23,7 +23,7 @@
#
##############################################################################
from openerp.tests.common import TransactionCase
from openerp.exceptions import Warning
from openerp.exceptions import Warning as UserError
class TestAccountBankStatementImport(TransactionCase):
@@ -68,12 +68,12 @@ class TestAccountBankStatementImport(TransactionCase):
stmt_vals = {
'currency_code': 'EUR',
'account_number': '123456789'}
with self.assertRaises(Warning) as e:
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')
with self.assertRaises(Warning) as e:
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.')