From 7d12ce19f12709106d855ae5667c7a437af3352c Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Fri, 2 Oct 2015 00:12:32 +0200 Subject: [PATCH] [FIX] Import exceptions.Warning as UserError. This according to OCA guidelines. Also reformat README.rst to keep lines within limit. --- account_bank_statement_import/__openerp__.py | 4 +- .../models/account_bank_statement_import.py | 5 ++- .../tests/test_import_bank_statement.py | 6 +-- .../__openerp__.py | 2 +- .../__openerp__.py | 2 +- .../README.rst | 2 +- .../__openerp__.py | 2 +- .../__openerp__.py | 3 +- .../__openerp__.py | 5 ++- .../account_bank_statement_import_ofx.py | 8 ++-- .../__openerp__.py | 4 +- .../account_bank_statement_import_qif.py | 10 +++-- .../__openerp__.py | 36 +++++++----------- .../test_files/test-camt053.zip | Bin 3111 -> 0 bytes base_bank_account_number_unique/README.rst | 31 +++++++++++---- .../__openerp__.py | 22 +++++------ base_bank_account_number_unique/hooks.py | 7 ++-- .../test_base_bank_account_number_unique.py | 4 +- 18 files changed, 84 insertions(+), 69 deletions(-) delete mode 100644 bank_statement_parse_camt/test_files/test-camt053.zip diff --git a/account_bank_statement_import/__openerp__.py b/account_bank_statement_import/__openerp__.py index 31df646..6961e9a 100644 --- a/account_bank_statement_import/__openerp__.py +++ b/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': [ 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 47a6f56..a9e07f1 100644 --- a/account_bank_statement_import/models/account_bank_statement_import.py +++ b/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 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 e32051a..42021ab 100644 --- a/account_bank_statement_import/tests/test_import_bank_statement.py +++ b/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.') diff --git a/account_bank_statement_import_camt/__openerp__.py b/account_bank_statement_import_camt/__openerp__.py index 47113f3..d54abd6 100644 --- a/account_bank_statement_import_camt/__openerp__.py +++ b/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', diff --git a/account_bank_statement_import_mt940_base/__openerp__.py b/account_bank_statement_import_mt940_base/__openerp__.py index c701d42..d821ce3 100644 --- a/account_bank_statement_import_mt940_base/__openerp__.py +++ b/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', diff --git a/account_bank_statement_import_mt940_nl_ing/README.rst b/account_bank_statement_import_mt940_nl_ing/README.rst index 631543d..2f9107e 100644 --- a/account_bank_statement_import_mt940_nl_ing/README.rst +++ b/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 diff --git a/account_bank_statement_import_mt940_nl_ing/__openerp__.py b/account_bank_statement_import_mt940_nl_ing/__openerp__.py index fa91932..6cad8a5 100644 --- a/account_bank_statement_import_mt940_nl_ing/__openerp__.py +++ b/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', diff --git a/account_bank_statement_import_mt940_nl_rabo/__openerp__.py b/account_bank_statement_import_mt940_nl_rabo/__openerp__.py index c01e7e3..90f0239 100644 --- a/account_bank_statement_import_mt940_nl_rabo/__openerp__.py +++ b/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', diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 329859e..6d9c327 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/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', diff --git a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py b/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py index 9358ae1..b03af72 100644 --- a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py +++ b/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, diff --git a/account_bank_statement_import_qif/__openerp__.py b/account_bank_statement_import_qif/__openerp__.py index 14a81a0..fb33246 100644 --- a/account_bank_statement_import_qif/__openerp__.py +++ b/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', diff --git a/account_bank_statement_import_qif/account_bank_statement_import_qif.py b/account_bank_statement_import_qif/account_bank_statement_import_qif.py index 0b9061e..b217e65 100644 --- a/account_bank_statement_import_qif/account_bank_statement_import_qif.py +++ b/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, diff --git a/account_bank_statement_import_save_file/__openerp__.py b/account_bank_statement_import_save_file/__openerp__.py index bdf5a38..20c735c 100644 --- a/account_bank_statement_import_save_file/__openerp__.py +++ b/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 . +# Copyright (C) 2015 Therp BV . # # 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, } diff --git a/bank_statement_parse_camt/test_files/test-camt053.zip b/bank_statement_parse_camt/test_files/test-camt053.zip deleted file mode 100644 index ccf5b3c2ba72ad03cc137edcf2ee55f67b7a2952..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3111 zcmeH}=T{S08pZ=5FccF7R764P14xk;5EP_{0RmY=5O4w{AVr!$C=oHlAWJhyReBE! zAqJ!U#$s;Q+O;qQmC7X$#CFp;S53XKp3 z@bIyK0Kng`kJ*<4=k&#UW|xqT(@Tov5YUyorl#QtnL>GL823Dkl9(M6fc0cI%(|Ni z6Q^GLcu71wsM2}%?CvjH!8b!s<&9$V%#|&29fp7$*Z6H3|gs9r@Iab`}w zn70^AGxt!43sw21&ugEeu5!s zB=aSvS|O$Bs(_1W`3N!7kW{?C+9uvd?a-AuvRv(>X!goeIdlV;b{mCeyP1vK$0=9p zhvGziT|Owbw0q_obsli0rv4Sr^-c(wMC`04QcZhDwWKHp@XFHQlHEbhsWMKSBZZOw zA}>C4#%A3WrP-sj`HDO4lA-;!yrBVX&3%#eOMKMU@+IV(nv7lhYS%{;$3{6@D@-?8 zj%$0W-f~sSJ^sQi^P9;MO$$IZFznJn;)6b5Ft;O?XIp3Wvr?Mxgx4Co_F1d*^z6>W z16A~WLf`!H5cIp~GA4ZCR{`G`WEw$zws*gec}$;&fZM zo5o5(B`9uG=!A2Ina*WDMms&g&>^6!qHt5;GqTVR1>*Ec+Z)I*wlOs-1v{7k(SD7cx&3TX>4UUU|z4aL*H}d*MEMlY`)`QpML{Lh>UZ>Y$ z#RRHb?tB{p^?Uws=MQd|l>2$Th%nhp47tF`Rx7B!RoxbGo{x9Ijt)~YQ+V444% zPzs&KG$xTJ)T2(Qz^8|QRB}mXgGS2uVz8>+^ZoN75^~j6MqhVW51<$wUzWDyF|J1 zirME@jT#|^OHAAz3aV0H+~Jxv^`tk-VY6f-Rl*g=@Y-F-Ba{e9gU80nOv-XmG14&C zV(E)5%on5Y=I7h_Gab0duA42{ST}8V<9on@o5adK;Lj4$TmL;iTZRlaNcE zF1&6LTv;hka~iWF8};~H>r~tMthOl-2An0f&eCUPY+h! z>c3ZOHlMoCRY`(}DnQqY19eBIViuA`HhKm_r5I4{dR+8rdB$SfS*>Oa_D7-8&b&W) z{U@*guX)YGD-Hakf-SLEya527J(Uu_PrqBYLI0@RzhO7R`d`NX9R>ex{Ae#A{?quM b!LVoiJE4HE2JwIY3-8{k*?V1uzi)p7q~E=A diff --git a/base_bank_account_number_unique/README.rst b/base_bank_account_number_unique/README.rst index d5dd3f2..9c3dc23 100644 --- a/base_bank_account_number_unique/README.rst +++ b/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 =========== diff --git a/base_bank_account_number_unique/__openerp__.py b/base_bank_account_number_unique/__openerp__.py index 9e6f23d..95a8308 100644 --- a/base_bank_account_number_unique/__openerp__.py +++ b/base_bank_account_number_unique/__openerp__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# This module copyright (C) 2015 Therp BV . +# Copyright (C) 2015 Therp BV . # # 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, } diff --git a/base_bank_account_number_unique/hooks.py b/base_bank_account_number_unique/hooks.py index 8bcdca3..a8fdb76 100644 --- a/base_bank_account_number_unique/hooks.py +++ b/base_bank_account_number_unique/hooks.py @@ -17,11 +17,12 @@ # along with this program. If not, see . # ############################################################################## -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) diff --git a/base_bank_account_number_unique/tests/test_base_bank_account_number_unique.py b/base_bank_account_number_unique/tests/test_base_bank_account_number_unique.py index de36ea9..0c87638 100644 --- a/base_bank_account_number_unique/tests/test_base_bank_account_number_unique.py +++ b/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)