Browse Source

[FIX] Import exceptions.Warning as UserError.

This according to OCA guidelines.
Also reformat README.rst to keep lines within limit.
pull/36/head
Ronald Portier (Therp BV) 9 years ago
parent
commit
7d12ce19f1
  1. 4
      account_bank_statement_import/__openerp__.py
  2. 5
      account_bank_statement_import/models/account_bank_statement_import.py
  3. 6
      account_bank_statement_import/tests/test_import_bank_statement.py
  4. 2
      account_bank_statement_import_camt/__openerp__.py
  5. 2
      account_bank_statement_import_mt940_base/__openerp__.py
  6. 2
      account_bank_statement_import_mt940_nl_ing/README.rst
  7. 2
      account_bank_statement_import_mt940_nl_ing/__openerp__.py
  8. 3
      account_bank_statement_import_mt940_nl_rabo/__openerp__.py
  9. 5
      account_bank_statement_import_ofx/__openerp__.py
  10. 8
      account_bank_statement_import_ofx/account_bank_statement_import_ofx.py
  11. 4
      account_bank_statement_import_qif/__openerp__.py
  12. 10
      account_bank_statement_import_qif/account_bank_statement_import_qif.py
  13. 36
      account_bank_statement_import_save_file/__openerp__.py
  14. BIN
      bank_statement_parse_camt/test_files/test-camt053.zip
  15. 31
      base_bank_account_number_unique/README.rst
  16. 22
      base_bank_account_number_unique/__openerp__.py
  17. 7
      base_bank_account_number_unique/hooks.py
  18. 4
      base_bank_account_number_unique/tests/test_base_bank_account_number_unique.py

4
account_bank_statement_import/__openerp__.py

@ -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': [

5
account_bank_statement_import/models/account_bank_statement_import.py

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

6
account_bank_statement_import/tests/test_import_bank_statement.py

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

2
account_bank_statement_import_camt/__openerp__.py

@ -19,7 +19,7 @@
##############################################################################
{
'name': 'CAMT Format Bank Statements Import',
'version': '8.0.0.3.0',
'version': '8.0.1.0.4',
'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Therp BV',
'website': 'https://github.com/OCA/bank-statement-import',

2
account_bank_statement_import_mt940_base/__openerp__.py

@ -19,7 +19,7 @@
##############################################################################
{
'name': 'MT940 Bank Statements Import',
'version': '8.0.1.1.0',
'version': '8.0.1.1.1',
'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Therp BV',
'website': 'https://github.com/OCA/bank-statement-import',

2
account_bank_statement_import_mt940_nl_ing/README.rst

@ -7,7 +7,7 @@ Import MT940 IBAN ING Bank Statements
This module allows you to import the MT940 IBAN files from the Dutch ING bank
in Odoo as bank statements.
The specifications are published at:
https://www.ing.nl/media/ING_ming_mt940s_24_juli_tcm162-46356.pdf
https://www.ing.nl/media/ING_ming_mt940s_24_juli_tcm162-46356.pdf
and were last updated august 2014.
Known issues / Roadmap

2
account_bank_statement_import_mt940_nl_ing/__openerp__.py

@ -19,7 +19,7 @@
##############################################################################
{
'name': 'MT940 IBAN ING Format Bank Statements Import',
'version': '8.0.0.3.0',
'version': '8.0.1.0.4',
'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Therp BV',
'website': 'https://github.com/OCA/bank-statement-import',

3
account_bank_statement_import_mt940_nl_rabo/__openerp__.py

@ -19,7 +19,8 @@
##############################################################################
{
'name': 'MT940 import for dutch Rabobank',
'version': '8.0.1.1.0',
'version': '8.0.1.1.1',
'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Therp BV',
'website': 'https://github.com/OCA/bank-statement-import',
'category': 'Banking addons',

5
account_bank_statement_import_ofx/__openerp__.py

@ -1,8 +1,9 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
{
'name': 'Import OFX Bank Statement',
'category': 'Banking addons',
'version': '8.0.1.0.0',
'version': '8.0.1.0.1',
'license': 'AGPL-3',
'author': 'OpenERP SA,'
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/bank-statement-import',

8
account_bank_statement_import_ofx/account_bank_statement_import_ofx.py

@ -5,7 +5,7 @@ import StringIO
from openerp import api, models
from openerp.tools.translate import _
from openerp.exceptions import Warning
from openerp.exceptions import Warning as UserError
_logger = logging.getLogger(__name__)
@ -64,8 +64,10 @@ class AccountBankStatementImport(models.TransientModel):
total_amt += float(transaction.amount)
transactions.append(vals_line)
except Exception, e:
raise Warning(_("The following problem occurred during import. "
"The file might not be valid.\n\n %s" % e.message))
raise UserError(_(
"The following problem occurred during import. "
"The file might not be valid.\n\n %s" % e.message
))
vals_bank_statement = {
'name': ofx.account.routing_number,

4
account_bank_statement_import_qif/__openerp__.py

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
{
'name': 'Import QIF Bank Statement',
'category': 'Banking addons',
'version': '8.0.1.0.0',
'version': '8.0.1.0.1',
'license': 'AGPL-3',
'author': 'OpenERP SA,'
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/bank-statement-import',

10
account_bank_statement_import_qif/account_bank_statement_import_qif.py

@ -5,7 +5,7 @@ import StringIO
from openerp.tools.translate import _
from openerp import api, models
from openerp.exceptions import Warning
from openerp.exceptions import Warning as UserError
class AccountBankStatementImport(models.TransientModel):
@ -36,7 +36,7 @@ class AccountBankStatementImport(models.TransientModel):
header = data_list[0].strip()
header = header.split(":")[1]
except:
raise Warning(_('Could not decipher the QIF file.'))
raise UserError(_('Could not decipher the QIF file.'))
transactions = []
vals_line = {}
total = 0
@ -80,8 +80,10 @@ class AccountBankStatementImport(models.TransientModel):
else:
pass
else:
raise Warning(_('This file is either not a bank statement or is '
'not correctly formed.'))
raise UserError(_(
"This file is either not a bank statement or is "
"not correctly formed."
))
vals_bank_statement.update({
'balance_end_real': total,

36
account_bank_statement_import_save_file/__openerp__.py

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
# Copyright (C) 2015 Therp BV <http://therp.nl>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -19,27 +18,20 @@
#
##############################################################################
{
"name": "Save imported bank statements",
"version": "8.0.1.0.0",
"author": "Therp BV",
"license": "AGPL-3",
"category": "Accounting & Finance",
"summary": "Keep imported bank statements as raw data",
"depends": [
'name': 'Save imported bank statements',
'version': '8.0.1.0.1',
'author': 'Odoo Community Association (OCA), Therp BV',
'license': 'AGPL-3',
'category': 'Banking addons',
'summary': 'Keep imported bank statements as raw data',
'depends': [
'account_bank_statement_import',
],
"data": [
"views/account_bank_statement.xml",
'data': [
'views/account_bank_statement.xml',
],
"qweb": [
],
"test": [
],
"post_init_hook": '_post_init_hook',
"auto_install": False,
"installable": True,
"application": False,
"external_dependencies": {
'python': [],
},
'post_init_hook': '_post_init_hook',
'auto_install': False,
'installable': True,
'application': False,
}

BIN
bank_statement_parse_camt/test_files/test-camt053.zip

31
base_bank_account_number_unique/README.rst

@ -1,20 +1,35 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3
Unique bank account numbers
===========================
It can be desirable to be able to rely on a bank account number identifying exactly one partner. This module allows you to enforce this, so that an account number is unique in the system.
It can be desirable to be able to rely on a bank account number identifying
exactly one partner. This module allows you to enforce this, so that an
account number is unique in the system.
Installation
============
During installation, the module checks if your bank account numbers are unique already. If this is not the case, you won't be able to install the module until duplicates are fixed.
The error message only shows the first few duplicates, in order to find all of them, use the following statement::
with res_partner_bank_sanitized as (select id, acc_number, regexp_replace(acc_number, '\W+', '', 'g') acc_number_sanitized from res_partner_bank),
res_partner_bank_sanitized_grouped as (select array_agg(id) ids, acc_number_sanitized, count(*) amount from res_partner_bank_sanitized group by acc_number_sanitized)
select * from res_partner_bank_sanitized_grouped where amount > 1;
During installation, the module checks if your bank account numbers are
unique already. If this is not the case, you won't be able to install the
module until duplicates are fixed.
The error message only shows the first few duplicates, in order to find all
of them, use the following statement::
with res_partner_bank_sanitized as (
select
id, acc_number,
regexp_replace(acc_number, '\W+', '', 'g') acc_number_sanitized
from res_partner_bank
),
res_partner_bank_sanitized_grouped as (
select
array_agg(id) ids, acc_number_sanitized, count(*) amount
from res_partner_bank_sanitized group by acc_number_sanitized
)
select * from res_partner_bank_sanitized_grouped where amount > 1;
Bug Tracker
===========

22
base_bank_account_number_unique/__openerp__.py

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
# Copyright (C) 2015 Therp BV <http://therp.nl>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -18,16 +18,16 @@
#
##############################################################################
{
"name": "Unique bank account numbers",
"version": "8.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Accounting & Finance",
"summary": "Enforce uniqueness on bank accounts",
"depends": [
'name': 'Unique bank account numbers',
'version': '8.0.1.0.1',
'author': 'Therp BV, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'category': 'Banking addons',
'summary': 'Enforce uniqueness on bank accounts',
'depends': [
'account_bank_statement_import',
],
"post_init_hook": "post_init_hook",
"auto_install": False,
"installable": True,
'post_init_hook': 'post_init_hook',
'auto_install': False,
'installable': True,
}

7
base_bank_account_number_unique/hooks.py

@ -17,11 +17,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import _, SUPERUSER_ID, exceptions
from openerp import _, SUPERUSER_ID
from openerp.exceptions import Warning as UserError
def post_init_hook(cr, pool):
'''check if your constraint was actually inserted, raise otherwise'''
"""check if your constraint was actually inserted, raise otherwise"""
if not pool['ir.model.constraint'].search(cr, SUPERUSER_ID, [
('name', '=', 'res_partner_bank_unique_number'),
('model.model', '=', 'res.partner.bank'),
@ -51,4 +52,4 @@ def post_init_hook(cr, pool):
max_account_numbers, '\n'.join(duplicates),
max_account_numbers,
)
raise exceptions.Warning(message)
raise UserError(message)

4
base_bank_account_number_unique/tests/test_base_bank_account_number_unique.py

@ -18,7 +18,7 @@
#
##############################################################################
from openerp.tests.common import TransactionCase
from openerp import exceptions
from openerp.exceptions import Warning as UserError
from ..hooks import post_init_hook
@ -38,5 +38,5 @@ class TestBaseBankAccountNumberUnique(TransactionCase):
'acc_number': 'BE 1234 567 890',
'state': 'bank',
})
with self.assertRaises(exceptions.Warning):
with self.assertRaises(UserError):
post_init_hook(self.cr, self.registry)
Loading…
Cancel
Save