From c9d8911a9291f85f2868370c14e6f4f87ab4a081 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 10:18:55 +0100 Subject: [PATCH 01/50] [RFR] Move backported bank import modules from bank-payment to bank-statement-import repository. --- account_bank_statement_import_ofx/__init__.py | 5 + .../__openerp__.py | 26 +++++ .../account_bank_statement_import_ofx.py | 74 +++++++++++++ .../test_ofx_file/test_ofx.ofx | 100 ++++++++++++++++++ .../tests/__init__.py | 5 + .../tests/test_import_bank_statement.py | 30 ++++++ 6 files changed, 240 insertions(+) create mode 100644 account_bank_statement_import_ofx/__init__.py create mode 100644 account_bank_statement_import_ofx/__openerp__.py create mode 100644 account_bank_statement_import_ofx/account_bank_statement_import_ofx.py create mode 100644 account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx create mode 100644 account_bank_statement_import_ofx/tests/__init__.py create mode 100644 account_bank_statement_import_ofx/tests/test_import_bank_statement.py diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py new file mode 100644 index 00000000..fe838c2d --- /dev/null +++ b/account_bank_statement_import_ofx/__init__.py @@ -0,0 +1,5 @@ +# -*- encoding: utf-8 -*- + +import account_bank_statement_import_ofx + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py new file mode 100644 index 00000000..8cd569bb --- /dev/null +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +{ + 'name': 'Import OFX Bank Statement', + 'version': '1.0', + 'author': 'OpenERP SA', + 'depends': ['account_bank_statement_import'], + 'demo': [], + 'description' : """ +Module to import OFX bank statements. +====================================== + +This module allows you to import the machine readable OFX Files in Odoo: they are parsed and stored in human readable format in +Accounting \ Bank and Cash \ Bank Statements. + +Bank Statements may be generated containing a subset of the OFX information (only those transaction lines that are required for the +creation of the Financial Accounting records). + +Backported from Odoo 9.0 + """, + 'data' : [], + 'demo': [], + 'auto_install': False, + 'installable': True, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: 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 new file mode 100644 index 00000000..13966c07 --- /dev/null +++ b/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +import logging +import base64 +import os + +from openerp.osv import osv +from openerp.tools.translate import _ + +_logger = logging.getLogger(__name__) + +from openerp.addons.account_bank_statement_import import account_bank_statement_import as ibs +ibs.add_file_type(('ofx', 'OFX')) + +try: + from ofxparse import OfxParser as ofxparser +except ImportError: + _logger.warning("OFX parser unavailable because the `ofxparse` Python library cannot be found." + "It can be downloaded and installed from `https://pypi.python.org/pypi/ofxparse`.") + ofxparser = None + +class account_bank_statement_import(osv.TransientModel): + _inherit = 'account.bank.statement.import' + + def process_ofx(self, cr, uid, data_file, journal_id=False, context=None): + """ Import a file in the .OFX format""" + if ofxparser is None: + raise osv.except_osv(_("Error"), _("OFX parser unavailable because the `ofxparse` Python library cannot be found." + "It can be downloaded and installed from `https://pypi.python.org/pypi/ofxparse`.")) + try: + tempfile = open("temp.ofx", "w+") + tempfile.write(base64.decodestring(data_file)) + tempfile.read() + pathname = os.path.dirname('temp.ofx') + path = os.path.join(os.path.abspath(pathname), 'temp.ofx') + ofx = ofxparser.parse(file(path)) + except: + raise osv.except_osv(_('Import Error!'), _('Please check OFX file format is proper or not.')) + line_ids = [] + total_amt = 0.00 + try: + for transaction in ofx.account.statement.transactions: + bank_account_id, partner_id = self._detect_partner(cr, uid, transaction.payee, identifying_field='owner_name', context=context) + vals_line = { + 'date': transaction.date, + 'name': transaction.payee + ': ' + transaction.memo, + 'ref': transaction.id, + 'amount': transaction.amount, + 'partner_id': partner_id, + 'bank_account_id': bank_account_id, + } + total_amt += float(transaction.amount) + line_ids.append((0, 0, vals_line)) + except Exception, e: + raise osv.except_osv(_('Error!'), _("Following problem has been occurred while importing your file, Please verify the file is proper or not.\n\n %s" % e.message)) + st_start_date = ofx.account.statement.start_date or False + st_end_date = ofx.account.statement.end_date or False + period_obj = self.pool.get('account.period') + if st_end_date: + period_ids = period_obj.find(cr, uid, st_end_date, context=context) + else: + period_ids = period_obj.find(cr, uid, st_start_date, context=context) + vals_bank_statement = { + 'name': ofx.account.routing_number, + 'balance_start': ofx.account.statement.balance, + 'balance_end_real': float(ofx.account.statement.balance) + total_amt, + 'period_id': period_ids and period_ids[0] or False, + 'journal_id': journal_id + } + vals_bank_statement.update({'line_ids': line_ids}) + os.remove(path) + return [vals_bank_statement] + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx b/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx new file mode 100644 index 00000000..37df4d0c --- /dev/null +++ b/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx @@ -0,0 +1,100 @@ + + + + + + + 0 + INFO + + 20130831165153.000[-8:PST] + ENG + + + + + 0 + + 0 + INFO + + + USD + + 000000123 + 123456 + CHECKING + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -80 + 219378 + Agrolait + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -90 + 219379 + China Export + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -100 + 219380 + Axelor Scuba + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -90 + 219381 + China Scuba + + + + 2156.56 + 20130831165153 + + + + + + + 0 + + 0 + INFO + + + USD + + 123412341234 + + + + + -562.00 + 20130831165153 + + + + + diff --git a/account_bank_statement_import_ofx/tests/__init__.py b/account_bank_statement_import_ofx/tests/__init__.py new file mode 100644 index 00000000..8a5a8e9b --- /dev/null +++ b/account_bank_statement_import_ofx/tests/__init__.py @@ -0,0 +1,5 @@ +from . import test_import_bank_statement + +checks = [ + test_import_bank_statement +] diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py new file mode 100644 index 00000000..967d647f --- /dev/null +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -0,0 +1,30 @@ +from openerp.tests.common import TransactionCase +from openerp.modules.module import get_module_resource + +class TestOfxFile(TransactionCase): + """Tests for import bank statement ofx file format (account.bank.statement.import) + """ + + def setUp(self): + super(TestOfxFile, self).setUp() + self.statement_import_model = self.registry('account.bank.statement.import') + self.bank_statement_model = self.registry('account.bank.statement') + + def test_ofx_file_import(self): + try: + from ofxparse import OfxParser as ofxparser + except ImportError: + #the Python library isn't installed on the server, the OFX import is unavailable and the test cannot be run + return True + cr, uid = self.cr, self.uid + ofx_file_path = get_module_resource('account_bank_statement_import_ofx', 'test_ofx_file', 'test_ofx.ofx') + ofx_file = open(ofx_file_path, 'rb').read().encode('base64') + bank_statement_id = self.statement_import_model.create(cr, uid, dict( + file_type='ofx', + data_file=ofx_file, + )) + self.statement_import_model.parse_file(cr, uid, [bank_statement_id]) + statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0] + bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) + self.assertEquals(bank_st_record.balance_start, 2156.56) + self.assertEquals(bank_st_record.balance_end_real, 1796.56) From 3c4f08dad3b2729bb353f58d2068e0c48a68fed5 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 12:00:52 +0100 Subject: [PATCH 02/50] [FIX] Change year in test files to 2014 [FIX] Change reference to not existing menu --- .../test_ofx_file/test_ofx.ofx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx b/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx index 37df4d0c..a1bf391b 100644 --- a/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx +++ b/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx @@ -7,7 +7,7 @@ 0 INFO - 20130831165153.000[-8:PST] + 20140831165153.000[-8:PST] ENG @@ -26,44 +26,44 @@ CHECKING - 20130801 - 20130831165153.000[-8:PST] + 20140801 + 20140831165153.000[-8:PST] POS - 20130824080000 + 20140824080000 -80 219378 Agrolait - 20130801 - 20130831165153.000[-8:PST] + 20140801 + 20140831165153.000[-8:PST] POS - 20130824080000 + 20140824080000 -90 219379 China Export - 20130801 - 20130831165153.000[-8:PST] + 20140801 + 20140831165153.000[-8:PST] POS - 20130824080000 + 20140824080000 -100 219380 Axelor Scuba - 20130801 - 20130831165153.000[-8:PST] + 20140801 + 20140831165153.000[-8:PST] POS - 20130824080000 + 20140824080000 -90 219381 China Scuba @@ -71,7 +71,7 @@ 2156.56 - 20130831165153 + 20140831165153 @@ -92,7 +92,7 @@ -562.00 - 20130831165153 + 20140831165153 From fe2e92ced6593b6437480abad8deaa8bd4c73ff5 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 12:37:19 +0100 Subject: [PATCH 03/50] [FIX] Add noqa tags to backported py files. --- .../account_bank_statement_import_ofx.py | 2 ++ .../tests/test_import_bank_statement.py | 3 +++ 2 files changed, 5 insertions(+) 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 13966c07..6f690a73 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 @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# noqa: This is a backport from Odoo. OCA has no control over style here. +# flake8: noqa import logging import base64 diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 967d647f..f804f90f 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -1,3 +1,6 @@ +# -*- coding: utf-8 -*- +# noqa: This is a backport from Odoo. OCA has no control over style here. +# flake8: noqa from openerp.tests.common import TransactionCase from openerp.modules.module import get_module_resource From 221832587bbe6445442205ded4617ef69df0e260 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 12:59:11 +0100 Subject: [PATCH 04/50] [FIX] Reverse change of year 2013 to 2014 in test files, and add warning to module descriptions that periods in 2013 should exist when using test-files. --- .../__openerp__.py | 4 +++ .../test_ofx_file/test_ofx.ofx | 30 +++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 8cd569bb..81429011 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -16,6 +16,10 @@ Bank Statements may be generated containing a subset of the OFX information (onl creation of the Financial Accounting records). Backported from Odoo 9.0 + +When testing with the provided test file, make sure the demo data from the +base account_bank_statement_import module has been imported, or manually +create periods for the year 2013. """, 'data' : [], 'demo': [], diff --git a/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx b/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx index a1bf391b..37df4d0c 100644 --- a/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx +++ b/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx @@ -7,7 +7,7 @@ 0 INFO - 20140831165153.000[-8:PST] + 20130831165153.000[-8:PST] ENG @@ -26,44 +26,44 @@ CHECKING - 20140801 - 20140831165153.000[-8:PST] + 20130801 + 20130831165153.000[-8:PST] POS - 20140824080000 + 20130824080000 -80 219378 Agrolait - 20140801 - 20140831165153.000[-8:PST] + 20130801 + 20130831165153.000[-8:PST] POS - 20140824080000 + 20130824080000 -90 219379 China Export - 20140801 - 20140831165153.000[-8:PST] + 20130801 + 20130831165153.000[-8:PST] POS - 20140824080000 + 20130824080000 -100 219380 Axelor Scuba - 20140801 - 20140831165153.000[-8:PST] + 20130801 + 20130831165153.000[-8:PST] POS - 20140824080000 + 20130824080000 -90 219381 China Scuba @@ -71,7 +71,7 @@ 2156.56 - 20140831165153 + 20130831165153 @@ -92,7 +92,7 @@ -562.00 - 20140831165153 + 20130831165153 From 47f407dbfffbef36120eda869d186856ff642d0b Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 14:07:54 +0100 Subject: [PATCH 05/50] [FIX] Apparently noqa tag should also be part of __openerp__.py files. --- account_bank_statement_import_ofx/__openerp__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 81429011..25056ddf 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -1,4 +1,6 @@ # -*- encoding: utf-8 -*- +# noqa: This is a backport from Odoo. OCA has no control over style here. +# flake8: noqa { 'name': 'Import OFX Bank Statement', 'version': '1.0', From 16bb27ee68b16ef9ea547f6e71257d1157419dec Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Sun, 21 Dec 2014 13:41:43 +0100 Subject: [PATCH 06/50] [FIX] Add noqa even to __init__.py files. --- account_bank_statement_import_ofx/__init__.py | 2 ++ account_bank_statement_import_ofx/tests/__init__.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py index fe838c2d..146530c8 100644 --- a/account_bank_statement_import_ofx/__init__.py +++ b/account_bank_statement_import_ofx/__init__.py @@ -1,4 +1,6 @@ # -*- encoding: utf-8 -*- +# noqa: This is a backport from Odoo. OCA has no control over style here. +# flake8: noqa import account_bank_statement_import_ofx diff --git a/account_bank_statement_import_ofx/tests/__init__.py b/account_bank_statement_import_ofx/tests/__init__.py index 8a5a8e9b..fa3fb309 100644 --- a/account_bank_statement_import_ofx/tests/__init__.py +++ b/account_bank_statement_import_ofx/tests/__init__.py @@ -1,3 +1,6 @@ +# -*- encoding: utf-8 -*- +# noqa: This is a backport from Odoo. OCA has no control over style here. +# flake8: noqa from . import test_import_bank_statement checks = [ From aa839c3cd066f7be707bbcb3dfe49069e053a966 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Sun, 21 Dec 2014 14:20:09 +0100 Subject: [PATCH 07/50] [FIX] Forgot to commit some __Init__.py files. --- account_bank_statement_import_ofx/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py index 146530c8..44bd24dc 100644 --- a/account_bank_statement_import_ofx/__init__.py +++ b/account_bank_statement_import_ofx/__init__.py @@ -1,7 +1,4 @@ # -*- encoding: utf-8 -*- -# noqa: This is a backport from Odoo. OCA has no control over style here. -# flake8: noqa - -import account_bank_statement_import_ofx +from . import account_bank_statement_import_ofx # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 8cc1a5229cf985491e13bb21f1bdb30096ceb446 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 23 Jan 2015 22:50:24 +0100 Subject: [PATCH 08/50] New backport from odoo/master Fix bug #5 --- .../__openerp__.py | 3 +- .../account_bank_statement_import_ofx.py | 71 ++++++++---------- .../static/description/icon.png | Bin 0 -> 6282 bytes .../tests/__init__.py | 4 - .../tests/test_import_bank_statement.py | 7 +- 5 files changed, 36 insertions(+), 49 deletions(-) create mode 100644 account_bank_statement_import_ofx/static/description/icon.png diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 25056ddf..8d2d4ee8 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -3,6 +3,7 @@ # flake8: noqa { 'name': 'Import OFX Bank Statement', + 'category' : 'Accounting & Finance', 'version': '1.0', 'author': 'OpenERP SA', 'depends': ['account_bank_statement_import'], @@ -28,5 +29,3 @@ create periods for the year 2013. 'auto_install': False, 'installable': True, } - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: 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 6f690a73..cf0eb8a3 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 @@ -3,74 +3,67 @@ # flake8: noqa import logging -import base64 -import os +import StringIO from openerp.osv import osv from openerp.tools.translate import _ +from openerp.exceptions import Warning _logger = logging.getLogger(__name__) -from openerp.addons.account_bank_statement_import import account_bank_statement_import as ibs -ibs.add_file_type(('ofx', 'OFX')) - try: from ofxparse import OfxParser as ofxparser except ImportError: - _logger.warning("OFX parser unavailable because the `ofxparse` Python library cannot be found." + _logger.error("OFX parser unavailable because the `ofxparse` Python library cannot be found." "It can be downloaded and installed from `https://pypi.python.org/pypi/ofxparse`.") ofxparser = None class account_bank_statement_import(osv.TransientModel): _inherit = 'account.bank.statement.import' - def process_ofx(self, cr, uid, data_file, journal_id=False, context=None): - """ Import a file in the .OFX format""" + def _check_ofx(self, cr, uid, file, context=None): if ofxparser is None: - raise osv.except_osv(_("Error"), _("OFX parser unavailable because the `ofxparse` Python library cannot be found." - "It can be downloaded and installed from `https://pypi.python.org/pypi/ofxparse`.")) + return False try: - tempfile = open("temp.ofx", "w+") - tempfile.write(base64.decodestring(data_file)) - tempfile.read() - pathname = os.path.dirname('temp.ofx') - path = os.path.join(os.path.abspath(pathname), 'temp.ofx') - ofx = ofxparser.parse(file(path)) + ofx = ofxparser.parse(file) except: - raise osv.except_osv(_('Import Error!'), _('Please check OFX file format is proper or not.')) - line_ids = [] + return False + return ofx + + def _parse_file(self, cr, uid, data_file, context=None): + ofx = self._check_ofx(cr, uid, StringIO.StringIO(data_file), context=context) + if not ofx: + return super(account_bank_statement_import, self)._parse_file(cr, uid, data_file, context=context) + + transactions = [] total_amt = 0.00 try: for transaction in ofx.account.statement.transactions: - bank_account_id, partner_id = self._detect_partner(cr, uid, transaction.payee, identifying_field='owner_name', context=context) + # Since ofxparse doesn't provide account numbers, we'll have to find res.partner and res.partner.bank here + # (normal behavious is to provide 'account_number', which the generic module uses to find partner/bank) + bank_account_id = partner_id = False + ids = self.pool.get('res.partner.bank').search(cr, uid, [('owner_name', '=', transaction.payee)], context=context) + if ids: + bank_account_id = bank_account_id = ids[0] + partner_id = self.pool.get('res.partner.bank').browse(cr, uid, bank_account_id, context=context).partner_id.id vals_line = { 'date': transaction.date, - 'name': transaction.payee + ': ' + transaction.memo, + 'name': transaction.payee + (transaction.memo and ': ' + transaction.memo or ''), 'ref': transaction.id, 'amount': transaction.amount, - 'partner_id': partner_id, + 'unique_import_id': transaction.id, 'bank_account_id': bank_account_id, + 'partner_id': partner_id, } total_amt += float(transaction.amount) - line_ids.append((0, 0, vals_line)) + transactions.append(vals_line) except Exception, e: - raise osv.except_osv(_('Error!'), _("Following problem has been occurred while importing your file, Please verify the file is proper or not.\n\n %s" % e.message)) - st_start_date = ofx.account.statement.start_date or False - st_end_date = ofx.account.statement.end_date or False - period_obj = self.pool.get('account.period') - if st_end_date: - period_ids = period_obj.find(cr, uid, st_end_date, context=context) - else: - period_ids = period_obj.find(cr, uid, st_start_date, context=context) + raise Warning(_("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, - 'balance_start': ofx.account.statement.balance, - 'balance_end_real': float(ofx.account.statement.balance) + total_amt, - 'period_id': period_ids and period_ids[0] or False, - 'journal_id': journal_id + 'transactions': transactions, + 'balance_start': float(ofx.account.statement.balance) - total_amt, + 'balance_end_real': float(ofx.account.statement.balance), } - vals_bank_statement.update({'line_ids': line_ids}) - os.remove(path) - return [vals_bank_statement] - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + return ofx.account.statement.currency, ofx.account.number, [vals_bank_statement] diff --git a/account_bank_statement_import_ofx/static/description/icon.png b/account_bank_statement_import_ofx/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c630877c1c5f76912c1e9197d3e688eb2f0e65d4 GIT binary patch literal 6282 zcma)BXHXMLv`(S-AiV_wN|B-@Aiac8yr=|hfJ!%nOAEbAD4}T}u|a6kRFEn`kRC+^ zF+flRK_E1x2Lur@0+0Luy_vT&=bYIyJNskjJMG&{^aWc%J{dj$03dkQ4&`)Y@&5@A z*OBfq^ZamRIKq%;FYz3$cpjgOqdhOq&Ls>0fVBK4zZQB2;Y&y;tGP==RfZq5iDxSwUT$_Da{#MTZEc(e7l}#@?XeMoW=D>q7FDHP!2kqGbq~ z$AY2^!Ry+>05`KyfPT45zsoTqlEr{9%#b$_0wz2ajsUQF?n7E?T4*j zhxFEHaCH93IDZEYs=F*Fa2b$)32js`!n$6eh zi83+*3Iinz#ut+yG$zR-2+)PatWNEJwQ%={t7I>u4?PLUFuYbJwE$dz_nzDr_mE^j zf9uNZ-zIzDZMGrH;;rm|J%l$8X;{RyJ2vug5$7Pxd{Tmi;HJd*#zrIh31@@h{kUTW ze7tsF(LscEcOV^f0(9o{J_HfyY?VeR7}u+4!p~3bf99(GdkRk(utc(x+aFz8_ztjU zfao53;biFmI!H3cnQ|hdc-viWPzSBJ~|0bicTDAH6hlJ9AR*V z@!wHy=QY;G=T%E_2;oFhZ%O)BkZH%KBy(V|vX_A*xra!j;|9ZL_%V^*YG(lCp2r!o z0vuNWojvr^qS4UbfCeVLjz0V(J0tF|JNBzDWFz`aQ`o6Fh&#_WU!|=*X+*+R7_ib( z=6%o%NTttVZ2gBAlpuk(wva@8Gy>|ex_anWKxszdT3%yQXxnM7c&X>V4W7N;^`mK^ zUMR#j2U%fnz=_9YZcNS)(AiS&Y1-whsKP-_>-D=O`L42%kH z5XK44%)(0)79DOEK@+B}S6u%5xM9I;+UE9E%Uy@7M7pUW_^rDG!EL>_4zEwNUL@a` zzisi=Xp&ioJD5w0XQhw$62t%%?NL^r5_J&&w1YpF{w=|+Nj075g>DHU^jdgsvOx|N z4=9rDkq#cw6B{|H-am$-5kI`QSfDs z|ZAc0u%&x zTLcVV(VLZw!L(tQN6yOSr$=Z-*n#P+(GB?}rDm>T)WoYG)KAzN03+utxXS1$%#ZwQ zW!I-qGJiTQvSNJldW$(u8+YTk*6T5m);lgFn1cF61@ZPJXi zv!=WYOuo9{#A3Pfc*AY%X{$8*S+*Bq;)Jqj#HEQCoi=t?lec(Z+pZ|iYVD;m_lJJ; z?u+M4ZGH`3qfxSGp3KZ1dN=ybL85H`TkgKtnV<^bnr&)CV5Kk5M-3y`yCPF7L>R**>*ZiL|w~iBg6P!0r#&*VWR|Qmys0Ylmf;ohlZbHSG6OZ?EC@*aM6aUZ~dg-o8K_r${v~X2) z2!gwru=JRS(f=|fNpW$n;1xi^Esg5*sGJrL+I581_weoAKA0)e`B&uLhIdm;I5ooJ zD*P+)A?*Zw$5!nGZwG&EYfJe}Shl0|iVX1YvDm(l5r8}Ly2rJNVEE+z*6$>bkPZ-W z(32KCux5nP-LQRztri$F=RUuBkscs`liR#c>AXG4o}%5xy5vCz_uLUHOx~dq+qBr* zSzdQ(yp{9murnbY-Z}i`8rkC5`$hSY@xrdu7F>e_PGoZ5rJ{H`36l|njnq|O}88E`|^A$gSI2cbof4A$DT?s-#j*>A-4IPgWSwhom4QqCRz&O z{VGgm&cS{P)Z4r(8=zs~vKy>8bgy|bhbJsF^NbdPQ&ehjJsFc3ZZ&wBM(7)LyZ4KI z=HrT;YSQlan03AiB5HA+GwmoU&$@QH*DP*RtSDrfWya4yRCbYh*^56M6^n-_w|IV8 zF0iUIR8c<5J+t?C6M=50s1mHMF?yZFuyO0e2r%XtR5)-sttKPI`z?zzGJo6|kx~mD zO$`N{;Z7dQxg<62jTx2YEHDv2c!Xc$>Liim#g?1`j^Z;fb(AJglg8G{C0(lc#BiOI z{jJ!@+X0H#jQ8!)Z@P6TRXZ+@!OZ?9nM{oEONahZ+VFucK<+ds3~({6U+-Q<5SX@E zPn(b*dNOC*776p65J-nXw1xw~ET?aEyid>VB)z7HA~c@_??axn^Aa#}z$sDhYI? z3$GUHPMoH{%Ny^dua&t@Ao}S+`qbOry%$bXe?32BQ^t!hk%4L3=9lfKq!Zy(s=wh= z)6J{8+quek3MSH~d0SYV_&^dT>AGrLx*V&XACz0ZjCj<6AMf*SIW^L*e&2kE&O%-M zwOp|UJRm(jU&P3$K23EmcWmZZ3dZc?-P_n7X`h_fLj6dwR=CP0iBdGrau{){bHmnj;Q3#_h=r|= zV=F%GS_|v=x&dGW@ugWk<(ty+kdVx}3_F_`U@HT{dxPI;)<^48-HoJFKil8yY76_< z^W-wz?bLhhIfPD{;XGH(CqagT+L{k z?mo2rLL0TRxp{w*UZcIZaBX@j7j$^<+u}-meQp}F^c(dR!#M`XpOm9G|2`Tn%Xd9z zZ7tDe`qlLq;4u;IyzDYu5VCH%z8p2;NfV7a49V8Nk@kcQTsnwK+pL51eS!0YkchNy zWxeM9siy_wwX`enIE8VwiBd(f{cs~y)Ok@!V1UlD&8}PTll{`7J)|ReF{%1rS;Za8 zQbXElY+yW~HnV)V=Mk|`8B8W)CAq(I`eacGh@u-n*>91L{OSZt_M zvs<*9|HfIEbMA@WQfa*C@8e!uwq-)=X~@SXV5_c1CkPvorX5GtS-|#%@1eYrlWRUO_P;=`fE9z-EC)Y;W}iTS6Lgq{mnL$ zUajrE`42*;67R9%u^ps_+CED-r*v|i0QGGYT8veN)##Qbps$wt&4AK!trWFY{@!OPZ_;7!b?XrcXFg#{F zqY~k5cIx3~2sgVtr8BEI)URUUu`Y2!MzD>BP@hJwdUU9?>*AQ=fM*4Th@`&aCZAfE z7b@nD2SrS>Gg5CM{xA^Tnz0(YL-~3Kf!KYrQ(HVR^5$%iiB0BX;v@Cgw$Re1`%seuhCceA1T+WRf{*F zA0gwwIS6XdEE{|xTsSp*X5Zfv)0^kQ4fprQbPi~iw}~0oJN&K_icpaK8APuMt6apw zSMQc)XCI{>sjA`UEX?S{eRmNZ<2UpRyopd>%wfh-$nHApAR6InAGE+Nc8}whgtSAN zveV_0ya?(mS}uLf%;$U|Q9yU7WG6;13vnP^;fSyrEUbU}!q2Bh@S+GXkofS~c}tQ+ z8#_!5wiF0oO-gpw2beo_zjs=XSJUR5OwIUoeM>Qk)y30#-59pvIkY(?E{)ITDcaRm z-1vyHX-rRisz3B_nL19%Uw$%b}276OaOF{a_8UoNjun z29A=^UA|y-_5|F~c@*Td?7{swPw8+UHKTxl3tEGo%Mt+77B;w7LCiyiW$O8jK%Ia$(xeDPV%f(99o)c?0~{jvCu4uCE7*IEdQfZr%G`_C%R+0ImOW&Q| zb>PcNNNI{f^&R+Qb~jIt?Sw^Py+@C{(oILx?c1(au8w-E=bKX(vI2%m>36MEOP1r6 z^A8f!Y&JaZ-%Zf|SYO?@--Uuforj}jcU%oA_;xy!Ig`=S?6Dto*2@o?S%NWT$ z|I?+G6=RH3o>To~fTLE%|B!Rt(ne69s`m)OE?CL46;~Fb-7LiB$0#Y=AYIcnUxti{ zcA+^(?KuByy$d#-oiPB8WiqujYVJTYe!XF*kQ)nubq zFz?xfOP%SCg;vMg7QfNDLpFcuzqNf0l!+hcPSI@TMOX@vI&>5T)3LK`LmV-ETANc0 zt~2u#+h4>dKv&lB(ERxJY3cILkR9^^z_=16Ab? zmA^QUsCY6e9;H0z?1w30G%+O&E8Z!W$?(QnKjF(tdKc?X1NYsP7~-!)`3L$Q!6vV; zw62$te<&kb+1l4(GD3H=h%c9neJQ_%y(YNn-uJd0I1Z_UNlaYk*5n)GCS-LJQ$6_` zb;6M*YX1lgJWU`bAC=PEBtEGj{yak8q)~;}3)^$Ij>Y1}w?OY;p0UuXE5ilG3YPF! z)94|Mf07a}Uw#Y4x1@Oe%wF=p{DWIMDgm`#P@Aru#T#q@eU?UQh^air zM4jtuCN)s7Q^gYO=_HW-Aj)UW(I+iI-%7q->DZ2`T}eKeY4u9IwK=rtt>?&|#rQp1 zToSj};Vv=+Na11L81dXCYmOCIQSQ>3F{3AKK;=c9Tm)~!vn3RHNQTcDxNH!n=v-#; z@P_F?&1DqG-|wO--1rmyg0_4GO8^;|Xlr}AdsD&zU!Ct5xQD)}Gn z%R`T+7pKC)o|d4g1g!1A+rH?ZH+>jYD3h5#nt?I|hI1Vz?zI=MYLNxC^xJBqks%c-|wp1g>mAkQimpIi$ zon`e)$U?e~(DN(n<))5vOY>@&*#MtcCK7=Whx(#l2G!#KeqjEO=btA9!e3cFI!_$y?Sj#>@-ddPdz%_Dej}t zc&RIuqeTmr``*6%9|}j=uCRfww0rvW{wKzmotupK2Y%<2kp(tP#`w{MvBp@DB@3=QVR{?GrLfU<;WXp1$@zHODMoP&m zqXm~H=QLF+l_8~5IR;4gl|=_NBR*5`WLn;a{!hj7v9_somh3=)UgKn-_47S8Z{xP-E78M(7=7OW1uMhUgu9Kz87pQu`k7Gvm& zYw;TQ7+#y&e}JnEE~DI3&;NY41MtsD9U4Oh+WBTntm*RFgV{e!$1~9R@opAJnGbTF3|5H&-pp3f znW1&y>-rusxCeaTBCq1X&ca+y|dR&Zn#J~5yGSo-L#;=q}y@LTaolx1+$Fbj^gU zfF!#q#|-Z4L6`!xt-h5_(KcQ4s%iidxvi)>a|iW=8F)0B<_I8Hk$Y-fn;@UbR=MRZ zHsq>-Brn|!Zj4P?MaVsv-?gz-GPFou!|KYF40k5+=1a)L@ Date: Mon, 2 Feb 2015 12:47:56 +0100 Subject: [PATCH 09/50] Adapt start/end balance in the OFX test --- .../tests/test_import_bank_statement.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 2391fd16..4bdb2a10 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -28,5 +28,5 @@ class TestOfxFile(TransactionCase): self.statement_import_model.import_file(cr, uid, [bank_statement_id]) statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0] bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) - self.assertEquals(bank_st_record.balance_start, 2156.56) - self.assertEquals(bank_st_record.balance_end_real, 1796.56) + self.assertEquals(bank_st_record.balance_start, 2516.56) + self.assertEquals(bank_st_record.balance_end_real, 2156.56) From 1356747b73a4d45ce21dbe71ba4154807e35c866 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 2 Feb 2015 12:56:30 +0100 Subject: [PATCH 10/50] Enable allow_auto_create_journal in the automated tests --- .../tests/test_import_bank_statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 4bdb2a10..ebdbe11d 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -25,7 +25,7 @@ class TestOfxFile(TransactionCase): bank_statement_id = self.statement_import_model.create(cr, uid, dict( data_file=ofx_file, )) - self.statement_import_model.import_file(cr, uid, [bank_statement_id]) + self.statement_import_model.import_file(cr, uid, [bank_statement_id], {'allow_auto_create_journal': True}) statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0] bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) self.assertEquals(bank_st_record.balance_start, 2516.56) From 30c705835631a8e244aec45a6c9f1ba06f5a22d3 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Sat, 7 Feb 2015 02:09:35 +0100 Subject: [PATCH 11/50] [FIX] Make flake and pylint happy. No automatic creation of journals. Provide demo data to succesfully run tests. --- .../__openerp__.py | 4 ++- .../demo/demo_data.xml | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 account_bank_statement_import_ofx/demo/demo_data.xml diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 8d2d4ee8..8a10b59b 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -25,7 +25,9 @@ base account_bank_statement_import module has been imported, or manually create periods for the year 2013. """, 'data' : [], - 'demo': [], + 'demo': [ + 'demo/demo_data.xml', + ], 'auto_install': False, 'installable': True, } diff --git a/account_bank_statement_import_ofx/demo/demo_data.xml b/account_bank_statement_import_ofx/demo/demo_data.xml new file mode 100644 index 00000000..8387f272 --- /dev/null +++ b/account_bank_statement_import_ofx/demo/demo_data.xml @@ -0,0 +1,27 @@ + + + + + + Bank Journal - (test ofx) + TBNKOFX + bank + + + + + + + + + Your Company + 123456 + + + + bank + + + + + From bb700f04ed9242629117c1dbfec93079f008fbfd Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Fri, 20 Mar 2015 11:48:55 +0100 Subject: [PATCH 12/50] [IMP] Backport from master at 04daefd2d101d90daf5782173b95f31f3bd9e1b6 --- account_bank_statement_import_ofx/__init__.py | 3 +-- account_bank_statement_import_ofx/__openerp__.py | 5 +++-- .../account_bank_statement_import_ofx.py | 7 +++---- .../tests/test_import_bank_statement.py | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py index 44bd24dc..99554388 100644 --- a/account_bank_statement_import_ofx/__init__.py +++ b/account_bank_statement_import_ofx/__init__.py @@ -1,4 +1,3 @@ # -*- encoding: utf-8 -*- -from . import account_bank_statement_import_ofx -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +import account_bank_statement_import_ofx diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 8a10b59b..c71cd778 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -25,9 +25,10 @@ base account_bank_statement_import module has been imported, or manually create periods for the year 2013. """, 'data' : [], + 'depends': ['account_bank_statement_import'], 'demo': [ 'demo/demo_data.xml', - ], - 'auto_install': False, + ], + 'auto_install': True, 'installable': True, } 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 cf0eb8a3..0442f030 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 @@ -14,8 +14,7 @@ _logger = logging.getLogger(__name__) try: from ofxparse import OfxParser as ofxparser except ImportError: - _logger.error("OFX parser unavailable because the `ofxparse` Python library cannot be found." - "It can be downloaded and installed from `https://pypi.python.org/pypi/ofxparse`.") + _logger.warn("ofxparse not found, OFX parsing disabled.") ofxparser = None class account_bank_statement_import(osv.TransientModel): @@ -63,7 +62,7 @@ class account_bank_statement_import(osv.TransientModel): vals_bank_statement = { 'name': ofx.account.routing_number, 'transactions': transactions, - 'balance_start': float(ofx.account.statement.balance) - total_amt, - 'balance_end_real': float(ofx.account.statement.balance), + 'balance_start': ofx.account.statement.balance, + 'balance_end_real': float(ofx.account.statement.balance) + total_amt, } return ofx.account.statement.currency, ofx.account.number, [vals_bank_statement] diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index ebdbe11d..2391fd16 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -25,8 +25,8 @@ class TestOfxFile(TransactionCase): bank_statement_id = self.statement_import_model.create(cr, uid, dict( data_file=ofx_file, )) - self.statement_import_model.import_file(cr, uid, [bank_statement_id], {'allow_auto_create_journal': True}) + self.statement_import_model.import_file(cr, uid, [bank_statement_id]) statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0] bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) - self.assertEquals(bank_st_record.balance_start, 2516.56) - self.assertEquals(bank_st_record.balance_end_real, 2156.56) + self.assertEquals(bank_st_record.balance_start, 2156.56) + self.assertEquals(bank_st_record.balance_end_real, 1796.56) From 1be4b48201b60d4a15b7aa8c434730a699c4adac Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Thu, 21 May 2015 14:03:51 +0200 Subject: [PATCH 13/50] [IMP] use new API Conflicts: account_bank_statement_import/account_bank_statement_import.py --- account_bank_statement_import_ofx/__init__.py | 2 +- .../account_bank_statement_import_ofx.py | 48 +++++++++++-------- .../tests/test_import_bank_statement.py | 27 ++++++----- 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py index 99554388..fb5e0c31 100644 --- a/account_bank_statement_import_ofx/__init__.py +++ b/account_bank_statement_import_ofx/__init__.py @@ -1,3 +1,3 @@ # -*- encoding: utf-8 -*- -import account_bank_statement_import_ofx +from . import account_bank_statement_import_ofx 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 0442f030..93c89313 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 @@ -1,11 +1,9 @@ # -*- coding: utf-8 -*- -# noqa: This is a backport from Odoo. OCA has no control over style here. -# flake8: noqa import logging import StringIO -from openerp.osv import osv +from openerp import api, models from openerp.tools.translate import _ from openerp.exceptions import Warning @@ -17,37 +15,46 @@ except ImportError: _logger.warn("ofxparse not found, OFX parsing disabled.") ofxparser = None -class account_bank_statement_import(osv.TransientModel): + +class account_bank_statement_import(models.TransientModel): _inherit = 'account.bank.statement.import' - def _check_ofx(self, cr, uid, file, context=None): + @api.model + def _check_ofx(self, data_file): if ofxparser is None: return False try: - ofx = ofxparser.parse(file) + ofx = ofxparser.parse(StringIO.StringIO(data_file)) except: return False return ofx - def _parse_file(self, cr, uid, data_file, context=None): - ofx = self._check_ofx(cr, uid, StringIO.StringIO(data_file), context=context) + @api.model + def _parse_file(self, data_file): + ofx = self._check_ofx(data_file) if not ofx: - return super(account_bank_statement_import, self)._parse_file(cr, uid, data_file, context=context) + return super(account_bank_statement_import, self)._parse_file( + data_file) transactions = [] total_amt = 0.00 try: for transaction in ofx.account.statement.transactions: - # Since ofxparse doesn't provide account numbers, we'll have to find res.partner and res.partner.bank here - # (normal behavious is to provide 'account_number', which the generic module uses to find partner/bank) + # Since ofxparse doesn't provide account numbers, we'll have + # to find res.partner and res.partner.bank here + # (normal behavious is to provide 'account_number', which the + # generic module uses to find partner/bank) bank_account_id = partner_id = False - ids = self.pool.get('res.partner.bank').search(cr, uid, [('owner_name', '=', transaction.payee)], context=context) - if ids: - bank_account_id = bank_account_id = ids[0] - partner_id = self.pool.get('res.partner.bank').browse(cr, uid, bank_account_id, context=context).partner_id.id + banks = self.env['res.partner.bank'].search( + [('owner_name', '=', transaction.payee)], limit=1) + if banks: + bank_account = banks[0] + bank_account_id = bank_account.id + partner_id = bank_account.partner_id.id vals_line = { 'date': transaction.date, - 'name': transaction.payee + (transaction.memo and ': ' + transaction.memo or ''), + 'name': transaction.payee + ( + transaction.memo and ': ' + transaction.memo or ''), 'ref': transaction.id, 'amount': transaction.amount, 'unique_import_id': transaction.id, @@ -57,12 +64,15 @@ class account_bank_statement_import(osv.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 Warning(_("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, 'transactions': transactions, 'balance_start': ofx.account.statement.balance, - 'balance_end_real': float(ofx.account.statement.balance) + total_amt, + 'balance_end_real': + float(ofx.account.statement.balance) + total_amt, } - return ofx.account.statement.currency, ofx.account.number, [vals_bank_statement] + return ofx.account.statement.currency, ofx.account.number, [ + vals_bank_statement] diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 2391fd16..578fe57b 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -4,29 +4,32 @@ from openerp.tests.common import TransactionCase from openerp.modules.module import get_module_resource + class TestOfxFile(TransactionCase): - """Tests for import bank statement ofx file format (account.bank.statement.import) + """Tests for import bank statement ofx file format + (account.bank.statement.import) """ def setUp(self): super(TestOfxFile, self).setUp() - self.statement_import_model = self.registry('account.bank.statement.import') - self.bank_statement_model = self.registry('account.bank.statement') + self.statement_import_model = self.env['account.bank.statement.import'] + self.bank_statement_model = self.env['account.bank.statement'] def test_ofx_file_import(self): try: from ofxparse import OfxParser as ofxparser except ImportError: - #the Python library isn't installed on the server, the OFX import is unavailable and the test cannot be run + # the Python library isn't installed on the server, the OFX import + # is unavailable and the test cannot be run return True - cr, uid = self.cr, self.uid - ofx_file_path = get_module_resource('account_bank_statement_import_ofx', 'test_ofx_file', 'test_ofx.ofx') + ofx_file_path = get_module_resource( + 'account_bank_statement_import_ofx', + 'test_ofx_file', 'test_ofx.ofx') ofx_file = open(ofx_file_path, 'rb').read().encode('base64') - bank_statement_id = self.statement_import_model.create(cr, uid, dict( - data_file=ofx_file, - )) - self.statement_import_model.import_file(cr, uid, [bank_statement_id]) - statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0] - bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) + bank_statement = self.statement_import_model.create( + dict(data_file=ofx_file)) + bank_statement.import_file() + bank_st_record = self.bank_statement_model.search( + [('name', '=', '000000123')])[0] self.assertEquals(bank_st_record.balance_start, 2156.56) self.assertEquals(bank_st_record.balance_end_real, 1796.56) From 648b66222c3fcde5565f3f45e71c7884be42507b Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Sun, 22 Mar 2015 22:11:24 +0100 Subject: [PATCH 14/50] [IMP] Improve test coverage --- .../tests/test_import_bank_statement.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 578fe57b..ad54f3dc 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -33,3 +33,12 @@ class TestOfxFile(TransactionCase): [('name', '=', '000000123')])[0] self.assertEquals(bank_st_record.balance_start, 2156.56) self.assertEquals(bank_st_record.balance_end_real, 1796.56) + + line = bank_st_record.line_ids[0] + self.assertEquals(line.name, 'Agrolait') + self.assertEquals(line.ref, '219378') + self.assertEquals(line.partner_id.id, self.ref('base.res_partner_2')) + self.assertEquals( + line.bank_account_id.id, + self.ref('account_bank_statement_import.ofx_partner_bank_1')) + From cd3a5b6261b560178b52d0e867fe9e6a499f0600 Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Fri, 3 Apr 2015 09:04:54 +0200 Subject: [PATCH 15/50] [IMP] Let the res_partner_bank.post_write create the journal if it doesn't exist --- .../__openerp__.py | 4 +-- .../demo/demo_data.xml | 27 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 account_bank_statement_import_ofx/demo/demo_data.xml diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index c71cd778..88329844 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -26,9 +26,7 @@ create periods for the year 2013. """, 'data' : [], 'depends': ['account_bank_statement_import'], - 'demo': [ - 'demo/demo_data.xml', - ], + 'demo': [], 'auto_install': True, 'installable': True, } diff --git a/account_bank_statement_import_ofx/demo/demo_data.xml b/account_bank_statement_import_ofx/demo/demo_data.xml deleted file mode 100644 index 8387f272..00000000 --- a/account_bank_statement_import_ofx/demo/demo_data.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - Bank Journal - (test ofx) - TBNKOFX - bank - - - - - - - - - Your Company - 123456 - - - - bank - - - - - From 77f726d99d827acc8a5e2e54521863094374e909 Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Fri, 5 Jun 2015 12:31:08 +0200 Subject: [PATCH 16/50] [IMP] Extract description to README Add OCA as author, PEP8 --- account_bank_statement_import_ofx/README.rst | 63 +++++++++++++++++++ .../__openerp__.py | 35 +++-------- .../account_bank_statement_import_ofx.py | 4 +- .../tests/test_import_bank_statement.py | 9 --- 4 files changed, 75 insertions(+), 36 deletions(-) create mode 100644 account_bank_statement_import_ofx/README.rst diff --git a/account_bank_statement_import_ofx/README.rst b/account_bank_statement_import_ofx/README.rst new file mode 100644 index 00000000..6fb12603 --- /dev/null +++ b/account_bank_statement_import_ofx/README.rst @@ -0,0 +1,63 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Import OFX Bank Statement +========================= + +This module allows you to import the machine readable OFX Files in Odoo: they are parsed and stored in human readable format in +Accounting \ Bank and Cash \ Bank Statements. + +Bank Statements may be generated containing a subset of the OFX information (only those transaction lines that are required for the +creation of the Financial Accounting records). + +The module has been initiated by a backport of the new framework developed +by Odoo for V9 at its early stage. It's no more kept in sync with the V9 since +it has reach a stage where maintaining a pure backport of 9.0 in 8.0 is not +feasible anymore + +Installation +============ + +The module requires one additional python lib: + +* `ofxparse `_ + +Known issues / Roadmap +====================== + +* None + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Odoo SA +* Alexis de Lattre +* Laurent Mignon +* Ronald Portier + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 88329844..212ac318 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -1,32 +1,17 @@ # -*- encoding: utf-8 -*- -# noqa: This is a backport from Odoo. OCA has no control over style here. -# flake8: noqa { 'name': 'Import OFX Bank Statement', - 'category' : 'Accounting & Finance', + 'category': 'Accounting & Finance', 'version': '1.0', - 'author': 'OpenERP SA', - 'depends': ['account_bank_statement_import'], - 'demo': [], - 'description' : """ -Module to import OFX bank statements. -====================================== - -This module allows you to import the machine readable OFX Files in Odoo: they are parsed and stored in human readable format in -Accounting \ Bank and Cash \ Bank Statements. - -Bank Statements may be generated containing a subset of the OFX information (only those transaction lines that are required for the -creation of the Financial Accounting records). - -Backported from Odoo 9.0 - -When testing with the provided test file, make sure the demo data from the -base account_bank_statement_import module has been imported, or manually -create periods for the year 2013. - """, - 'data' : [], - 'depends': ['account_bank_statement_import'], - 'demo': [], + 'author': 'OpenERP SA,' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/bank-statement-import', + 'depends': [ + 'account_bank_statement_import' + ], + 'external_dependencies': { + 'python': ['ofxparse'], + }, 'auto_install': True, 'installable': True, } 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 93c89313..9358ae12 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 @@ -16,7 +16,7 @@ except ImportError: ofxparser = None -class account_bank_statement_import(models.TransientModel): +class AccountBankStatementImport(models.TransientModel): _inherit = 'account.bank.statement.import' @api.model @@ -33,7 +33,7 @@ class account_bank_statement_import(models.TransientModel): def _parse_file(self, data_file): ofx = self._check_ofx(data_file) if not ofx: - return super(account_bank_statement_import, self)._parse_file( + return super(AccountBankStatementImport, self)._parse_file( data_file) transactions = [] diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index ad54f3dc..b35afa17 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# noqa: This is a backport from Odoo. OCA has no control over style here. -# flake8: noqa from openerp.tests.common import TransactionCase from openerp.modules.module import get_module_resource @@ -16,12 +14,6 @@ class TestOfxFile(TransactionCase): self.bank_statement_model = self.env['account.bank.statement'] def test_ofx_file_import(self): - try: - from ofxparse import OfxParser as ofxparser - except ImportError: - # the Python library isn't installed on the server, the OFX import - # is unavailable and the test cannot be run - return True ofx_file_path = get_module_resource( 'account_bank_statement_import_ofx', 'test_ofx_file', 'test_ofx.ofx') @@ -41,4 +33,3 @@ class TestOfxFile(TransactionCase): self.assertEquals( line.bank_account_id.id, self.ref('account_bank_statement_import.ofx_partner_bank_1')) - From 956ee4aac8824bd5c526f432fb1aaaf9bcad3f59 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Mon, 8 Jun 2015 11:13:41 +0200 Subject: [PATCH 17/50] [ADD] i18n --- .../account_bank_statement_import_ofx.pot | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot diff --git a/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot b/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot new file mode 100644 index 00000000..1c67dafa --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-08 09:11+0000\n" +"PO-Revision-Date: 2015-06-08 09:11+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#, python-format +msgid "The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" + From fc6ccdabc67ff58d110e44e2b5381e246ed86df5 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 9 Jun 2015 11:58:53 +0200 Subject: [PATCH 18/50] account_bank_statement_import_ofx is not automatically installed anymore --- account_bank_statement_import_ofx/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 212ac318..d54b072c 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -12,6 +12,6 @@ 'external_dependencies': { 'python': ['ofxparse'], }, - 'auto_install': True, + 'auto_install': False, 'installable': True, } From c062b7667587409e4c16084b8d5654e7b92a3d44 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Thu, 2 Apr 2015 10:56:50 +0200 Subject: [PATCH 19/50] [ENH] Support multiple accounts/currencies. Copy of changes proposed for master. --- .../account_bank_statement_import_ofx.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 9358ae12..94bd49ae 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 @@ -67,12 +67,12 @@ class AccountBankStatementImport(models.TransientModel): raise Warning(_("The following problem occurred during import. " "The file might not be valid.\n\n %s" % e.message)) - vals_bank_statement = { + return [{ + 'currency_code': ofx.account.statement.currency, + 'account_number': ofx.account.number, 'name': ofx.account.routing_number, 'transactions': transactions, 'balance_start': ofx.account.statement.balance, 'balance_end_real': float(ofx.account.statement.balance) + total_amt, - } - return ofx.account.statement.currency, ofx.account.number, [ - vals_bank_statement] + }] From 2bded2cb99bf950ec5b56c760cfed7bf37cd6f2d Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Thu, 11 Jun 2015 09:03:47 +0200 Subject: [PATCH 20/50] [FIX] Test of ofx should not fail due to USD currency used. --- .../__openerp__.py | 3 +++ .../demo/demo_data.xml | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 account_bank_statement_import_ofx/demo/demo_data.xml diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index d54b072c..ff7555d0 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -9,6 +9,9 @@ 'depends': [ 'account_bank_statement_import' ], + 'demo': [ + 'demo/demo_data.xml', + ], 'external_dependencies': { 'python': ['ofxparse'], }, diff --git a/account_bank_statement_import_ofx/demo/demo_data.xml b/account_bank_statement_import_ofx/demo/demo_data.xml new file mode 100644 index 00000000..8387f272 --- /dev/null +++ b/account_bank_statement_import_ofx/demo/demo_data.xml @@ -0,0 +1,27 @@ + + + + + + Bank Journal - (test ofx) + TBNKOFX + bank + + + + + + + + + Your Company + 123456 + + + + bank + + + + + From e3df1e435c94d1128097f15992bf558e9b270600 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Wed, 17 Jun 2015 12:32:34 +0200 Subject: [PATCH 21/50] [FIX] Copyright headers, vim line and manifest keys. --- account_bank_statement_import_ofx/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index ff7555d0..e81e2b53 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- { 'name': 'Import OFX Bank Statement', - 'category': 'Accounting & Finance', + 'category': 'Banking addons', 'version': '1.0', 'author': 'OpenERP SA,' 'Odoo Community Association (OCA)', From faf8817c28bace7e0c131b85f9dfe018d956e628 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Fri, 26 Jun 2015 16:02:10 +0200 Subject: [PATCH 22/50] [ENH] Support both old and new style parse results. --- .../account_bank_statement_import_ofx.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 94bd49ae..9358ae12 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 @@ -67,12 +67,12 @@ class AccountBankStatementImport(models.TransientModel): raise Warning(_("The following problem occurred during import. " "The file might not be valid.\n\n %s" % e.message)) - return [{ - 'currency_code': ofx.account.statement.currency, - 'account_number': ofx.account.number, + vals_bank_statement = { 'name': ofx.account.routing_number, 'transactions': transactions, 'balance_start': ofx.account.statement.balance, 'balance_end_real': float(ofx.account.statement.balance) + total_amt, - }] + } + return ofx.account.statement.currency, ofx.account.number, [ + vals_bank_statement] From d8612434e14af6abe4745be81983e12d706777f6 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Tue, 1 Sep 2015 12:20:23 -0400 Subject: [PATCH 23/50] OCA Transbot updated translations from Transifex --- account_bank_statement_import_ofx/i18n/en.po | 32 ++++++++++++++++++ account_bank_statement_import_ofx/i18n/es.po | 32 ++++++++++++++++++ account_bank_statement_import_ofx/i18n/fr.po | 33 +++++++++++++++++++ .../i18n/lt_LT.po | 33 +++++++++++++++++++ account_bank_statement_import_ofx/i18n/nl.po | 33 +++++++++++++++++++ account_bank_statement_import_ofx/i18n/sl.po | 33 +++++++++++++++++++ 6 files changed, 196 insertions(+) create mode 100644 account_bank_statement_import_ofx/i18n/en.po create mode 100644 account_bank_statement_import_ofx/i18n/es.po create mode 100644 account_bank_statement_import_ofx/i18n/fr.po create mode 100644 account_bank_statement_import_ofx/i18n/lt_LT.po create mode 100644 account_bank_statement_import_ofx/i18n/nl.po create mode 100644 account_bank_statement_import_ofx/i18n/sl.po diff --git a/account_bank_statement_import_ofx/i18n/en.po b/account_bank_statement_import_ofx/i18n/en.po new file mode 100644 index 00000000..8084e16a --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/en.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-05-29 00:41+0000\n" +"Last-Translator: OCA Transbot \n" +"Language-Team: English (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/en/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Import Bank Statement" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "The following problem occurred during import. The file might not be valid.\n\n %s" diff --git a/account_bank_statement_import_ofx/i18n/es.po b/account_bank_statement_import_ofx/i18n/es.po new file mode 100644 index 00000000..174f8f51 --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-05-29 00:50+0000\n" +"Last-Translator: OCA Transbot \n" +"Language-Team: Spanish (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importar extracto bancario" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/fr.po b/account_bank_statement_import_ofx/i18n/fr.po new file mode 100644 index 00000000..0125fee1 --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/fr.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# zuher83 , 2015 +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-06-28 20:24+0000\n" +"Last-Translator: zuher83 \n" +"Language-Team: French (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importer Relevé Bancaire" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "Le problème suivant est survenu lors de l'importation. Le fichier n'est pas valide.\n\n%s" diff --git a/account_bank_statement_import_ofx/i18n/lt_LT.po b/account_bank_statement_import_ofx/i18n/lt_LT.po new file mode 100644 index 00000000..866c553c --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/lt_LT.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# Arminas Grigonis , 2015 +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-07-23 13:36+0000\n" +"Last-Translator: Arminas Grigonis \n" +"Language-Team: Lithuanian (Lithuania) (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/lt_LT/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: lt_LT\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importuoti banko išrašą" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "Klaida. Failas gali būti sugadintas arba negaliojantis.\n\n %s" diff --git a/account_bank_statement_import_ofx/i18n/nl.po b/account_bank_statement_import_ofx/i18n/nl.po new file mode 100644 index 00000000..35482cc1 --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/nl.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# Erwin van der Ploeg , 2015 +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-08-17 19:03+0000\n" +"Last-Translator: Erwin van der Ploeg \n" +"Language-Team: Dutch (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/nl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importeer bankafschrift" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "Het volgende probleem is opgetreden tijdens de import. Het bestand is waarschijnlijk niet juist.\n\n%s" diff --git a/account_bank_statement_import_ofx/i18n/sl.po b/account_bank_statement_import_ofx/i18n/sl.po new file mode 100644 index 00000000..de6cae28 --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/sl.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# Matjaž Mozetič , 2015 +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-06-28 05:23+0000\n" +"Last-Translator: Matjaž Mozetič \n" +"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Uvoz bančnega izpiska" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "Med uvozom je prišlo do težav. Datoteka ni veljavna.\n\n %s" From 4102071323d1890928b3b685fe2ecae04b9ca337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 9 Oct 2015 09:59:36 +0200 Subject: [PATCH 24/50] [UPD] prefix versions with 8.0 --- account_bank_statement_import_ofx/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index e81e2b53..329859e7 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -2,7 +2,7 @@ { 'name': 'Import OFX Bank Statement', 'category': 'Banking addons', - 'version': '1.0', + 'version': '8.0.1.0.0', 'author': 'OpenERP SA,' 'Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/bank-statement-import', From 1e70f15888d51994aec0d8c6165400ef0cd650e0 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 10 Oct 2015 21:23:01 -0400 Subject: [PATCH 25/50] OCA Transbot updated translations from Transifex --- .../__openerp__.py | 2 +- .../i18n/{en.po => pt_BR.po} | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) rename account_bank_statement_import_ofx/i18n/{en.po => pt_BR.po} (59%) diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 329859e7..275bff9e 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -16,5 +16,5 @@ 'python': ['ofxparse'], }, 'auto_install': False, - 'installable': True, + 'installable': False, } diff --git a/account_bank_statement_import_ofx/i18n/en.po b/account_bank_statement_import_ofx/i18n/pt_BR.po similarity index 59% rename from account_bank_statement_import_ofx/i18n/en.po rename to account_bank_statement_import_ofx/i18n/pt_BR.po index 8084e16a..12bde786 100644 --- a/account_bank_statement_import_ofx/i18n/en.po +++ b/account_bank_statement_import_ofx/i18n/pt_BR.po @@ -3,24 +3,25 @@ # * account_bank_statement_import_ofx # # Translators: +# danimaribeiro , 2015 msgid "" msgstr "" "Project-Id-Version: bank-statement-import (8.0)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-24 21:51+0000\n" -"PO-Revision-Date: 2015-05-29 00:41+0000\n" -"Last-Translator: OCA Transbot \n" -"Language-Team: English (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/en/)\n" +"POT-Creation-Date: 2015-10-09 09:23+0000\n" +"PO-Revision-Date: 2015-10-09 00:24+0000\n" +"Last-Translator: danimaribeiro \n" +"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: en\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" -msgstr "Import Bank Statement" +msgstr "Importar extrato bancário" #. module: account_bank_statement_import_ofx #: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 @@ -29,4 +30,4 @@ msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" -msgstr "The following problem occurred during import. The file might not be valid.\n\n %s" +msgstr "O seguinte problema ocorreu durante a importação. O arquivo não deve ser válido.\n\n%s" From b7a896ae14d82e0cb7b846bd6ea58d06ecec4b7d Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 6 Oct 2016 14:47:55 +0200 Subject: [PATCH 26/50] [MIG] Rename manifest files --- .../{__openerp__.py => __manifest__.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename account_bank_statement_import_ofx/{__openerp__.py => __manifest__.py} (100%) diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__manifest__.py similarity index 100% rename from account_bank_statement_import_ofx/__openerp__.py rename to account_bank_statement_import_ofx/__manifest__.py From c3d4a0991186833509c1c4356e2021a88cc1344c Mon Sep 17 00:00:00 2001 From: Ilyas Date: Wed, 18 Nov 2015 14:50:48 +0500 Subject: [PATCH 27/50] Some changes for odoo 9.0 --- account_bank_statement_import_ofx/__manifest__.py | 2 +- .../account_bank_statement_import_ofx.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/account_bank_statement_import_ofx/__manifest__.py b/account_bank_statement_import_ofx/__manifest__.py index 275bff9e..329859e7 100644 --- a/account_bank_statement_import_ofx/__manifest__.py +++ b/account_bank_statement_import_ofx/__manifest__.py @@ -16,5 +16,5 @@ 'python': ['ofxparse'], }, 'auto_install': False, - 'installable': False, + 'installable': True, } 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 9358ae12..0a82d5fd 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 @@ -46,7 +46,7 @@ class AccountBankStatementImport(models.TransientModel): # generic module uses to find partner/bank) bank_account_id = partner_id = False banks = self.env['res.partner.bank'].search( - [('owner_name', '=', transaction.payee)], limit=1) + [('bank_name', '=', transaction.payee)], limit=1) if banks: bank_account = banks[0] bank_account_id = bank_account.id From f76a519575295c2eadfa06bbaed92827eaa76b1e Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 3 Jun 2016 16:04:20 +0200 Subject: [PATCH 28/50] [REF] OCA convention; [ADD] patch ofx parser to make this module work with some european bank like credit cooperatif; [IMP] wizard view to display OFX implementation; --- account_bank_statement_import_ofx/README.rst | 21 +++++++++- account_bank_statement_import_ofx/__init__.py | 5 +-- .../__manifest__.py | 15 +++++-- .../demo/demo_data.xml | 42 +++++++++---------- .../models/__init__.py | 2 + .../account_bank_statement_import.py} | 21 ++++------ .../models/ofx.py | 40 ++++++++++++++++++ .../tests/__init__.py | 4 +- .../tests/test_import_bank_statement.py | 2 +- .../{ => tests}/test_ofx_file/test_ofx.ofx | 0 .../view_account_bank_statement_import.xml | 12 ++++++ 11 files changed, 116 insertions(+), 48 deletions(-) create mode 100644 account_bank_statement_import_ofx/models/__init__.py rename account_bank_statement_import_ofx/{account_bank_statement_import_ofx.py => models/account_bank_statement_import.py} (84%) create mode 100644 account_bank_statement_import_ofx/models/ofx.py rename account_bank_statement_import_ofx/{ => tests}/test_ofx_file/test_ofx.ofx (100%) create mode 100644 account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml diff --git a/account_bank_statement_import_ofx/README.rst b/account_bank_statement_import_ofx/README.rst index 6fb12603..cc06cc11 100644 --- a/account_bank_statement_import_ofx/README.rst +++ b/account_bank_statement_import_ofx/README.rst @@ -1,6 +1,7 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg :alt: License: AGPL-3 +========================= Import OFX Bank Statement ========================= @@ -22,6 +23,21 @@ The module requires one additional python lib: * `ofxparse `_ +Technical Note +============== + +this module is based on ofxparse python lib and overload some of its functions. + +* For the time being the default ofxparse lib available with + 'pip install ofxparse' do not manage correctly european amount that are + written with ',' and not with '.'. (For exemple, The Credit Cooperatif + French Bank provides OFX 1.0 with amounts written with coma) + +April, 27 2016: this problem has been fixed here: +https://github.com/jseutter/ofxparse/commit/283f89c3246ed3fedccc3ef5c96078b7d5b94579 +but it is not available in the pip lib for the time being. + + Known issues / Roadmap ====================== @@ -40,12 +56,13 @@ Credits ======= Contributors ------------- +------------ -* Odoo SA +* Odoo SA * Alexis de Lattre * Laurent Mignon * Ronald Portier +* Sylvain LE GAL Maintainer ---------- diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py index fb5e0c31..a0fdc10f 100644 --- a/account_bank_statement_import_ofx/__init__.py +++ b/account_bank_statement_import_ofx/__init__.py @@ -1,3 +1,2 @@ -# -*- encoding: utf-8 -*- - -from . import account_bank_statement_import_ofx +# -*- coding: utf-8 -*- +from . import models diff --git a/account_bank_statement_import_ofx/__manifest__.py b/account_bank_statement_import_ofx/__manifest__.py index 329859e7..7e025449 100644 --- a/account_bank_statement_import_ofx/__manifest__.py +++ b/account_bank_statement_import_ofx/__manifest__.py @@ -1,13 +1,20 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- { 'name': 'Import OFX Bank Statement', 'category': 'Banking addons', - 'version': '8.0.1.0.0', + 'version': '9.0.0.0.0', + 'license': 'AGPL-3', 'author': 'OpenERP SA,' + 'La Louve,' + 'GRAP,' 'Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/bank-statement-import', + 'website': 'https://odoo-community.org/', 'depends': [ - 'account_bank_statement_import' + 'l10n_generic_coa', + 'account_bank_statement_import', + ], + 'data': [ + 'views/view_account_bank_statement_import.xml', ], 'demo': [ 'demo/demo_data.xml', diff --git a/account_bank_statement_import_ofx/demo/demo_data.xml b/account_bank_statement_import_ofx/demo/demo_data.xml index 8387f272..3a7a3520 100644 --- a/account_bank_statement_import_ofx/demo/demo_data.xml +++ b/account_bank_statement_import_ofx/demo/demo_data.xml @@ -1,27 +1,23 @@ - - + - - Bank Journal - (test ofx) - TBNKOFX - bank - - - - - - + + Bank Journal - (test ofx) + OFX/%(range_year)s/ + no_gap + 4 + 1 + - - Your Company - 123456 - - - - bank - - - - + + Bank Journal - (test ofx) + 123456 + TBNKOFX + bank + + + + + + diff --git a/account_bank_statement_import_ofx/models/__init__.py b/account_bank_statement_import_ofx/models/__init__.py new file mode 100644 index 00000000..5dfe830f --- /dev/null +++ b/account_bank_statement_import_ofx/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import account_bank_statement_import diff --git a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py b/account_bank_statement_import_ofx/models/account_bank_statement_import.py similarity index 84% rename from account_bank_statement_import_ofx/account_bank_statement_import_ofx.py rename to account_bank_statement_import_ofx/models/account_bank_statement_import.py index 0a82d5fd..c05ee739 100644 --- a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py +++ b/account_bank_statement_import_ofx/models/account_bank_statement_import.py @@ -5,27 +5,24 @@ import StringIO from openerp import api, models from openerp.tools.translate import _ -from openerp.exceptions import Warning +from openerp.exceptions import Warning as UserError + +from .ofx import OfxParser, OfxParser_ok _logger = logging.getLogger(__name__) -try: - from ofxparse import OfxParser as ofxparser -except ImportError: - _logger.warn("ofxparse not found, OFX parsing disabled.") - ofxparser = None - class AccountBankStatementImport(models.TransientModel): _inherit = 'account.bank.statement.import' @api.model def _check_ofx(self, data_file): - if ofxparser is None: + if not OfxParser_ok: return False try: - ofx = ofxparser.parse(StringIO.StringIO(data_file)) - except: + ofx = OfxParser.parse(StringIO.StringIO(data_file)) + except Exception as e: + _logger.debug(e) return False return ofx @@ -64,7 +61,7 @@ class AccountBankStatementImport(models.TransientModel): total_amt += float(transaction.amount) transactions.append(vals_line) except Exception, e: - raise Warning(_("The following problem occurred during import. " + raise UserError(_("The following problem occurred during import. " "The file might not be valid.\n\n %s" % e.message)) vals_bank_statement = { @@ -72,7 +69,7 @@ class AccountBankStatementImport(models.TransientModel): 'transactions': transactions, 'balance_start': ofx.account.statement.balance, 'balance_end_real': - float(ofx.account.statement.balance) + total_amt, + float(ofx.account.statement.balance) + total_amt, } return ofx.account.statement.currency, ofx.account.number, [ vals_bank_statement] diff --git a/account_bank_statement_import_ofx/models/ofx.py b/account_bank_statement_import_ofx/models/ofx.py new file mode 100644 index 00000000..d7469383 --- /dev/null +++ b/account_bank_statement_import_ofx/models/ofx.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +import logging + +_logger = logging.getLogger(__name__) + +try: + from ofxparse import OfxParser as OfxParserOriginal + OfxParser_ok = True +except ImportError: + _logger.warn("ofxparse not found, OFX parsing disabled.") + OfxParserOriginal = object + OfxParser_ok = False + + +class OfxParser(OfxParserOriginal): + """ Custom changes in the OFX Parser. + """ + + @classmethod + def _tagToDecimal(self, tag): + tag.string = tag.string.replace(',', '.') + + @classmethod + def parseStatement(cls_, stmt_ofx): + """Amount with ',' replaced by '.' in the following tags : + //LEDGERBAL/BALAMT + """ + ledgerbal_tag = stmt_ofx.find('ledgerbal') + if hasattr(ledgerbal_tag, "contents"): + cls_._tagToDecimal(ledgerbal_tag.find('balamt')) + return super(OfxParser, cls_).parseStatement(stmt_ofx) + + @classmethod + def parseTransaction(cls_, txn_ofx): + """Amount with ',' replaced by '.' in the following tags : + //TRNAMT + """ + cls_._tagToDecimal(txn_ofx.find('trnamt')) + return super(OfxParser, cls_).parseTransaction(txn_ofx) diff --git a/account_bank_statement_import_ofx/tests/__init__.py b/account_bank_statement_import_ofx/tests/__init__.py index 15a01408..9ce25a7f 100644 --- a/account_bank_statement_import_ofx/tests/__init__.py +++ b/account_bank_statement_import_ofx/tests/__init__.py @@ -1,4 +1,2 @@ -# -*- encoding: utf-8 -*- -# noqa: This is a backport from Odoo. OCA has no control over style here. -# flake8: noqa +# -*- coding: utf-8 -*- from . import test_import_bank_statement diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index b35afa17..0efe690a 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -16,7 +16,7 @@ class TestOfxFile(TransactionCase): def test_ofx_file_import(self): ofx_file_path = get_module_resource( 'account_bank_statement_import_ofx', - 'test_ofx_file', 'test_ofx.ofx') + 'tests/test_ofx_file/', 'test_ofx.ofx') ofx_file = open(ofx_file_path, 'rb').read().encode('base64') bank_statement = self.statement_import_model.create( dict(data_file=ofx_file)) diff --git a/account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx b/account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx.ofx similarity index 100% rename from account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx rename to account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx.ofx diff --git a/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml b/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml new file mode 100644 index 00000000..3f0892fa --- /dev/null +++ b/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml @@ -0,0 +1,12 @@ + + + + account.bank.statement.import + + + +
  • Open Financial Exchange (.OFX Money)
  • +
    +
    +
    +
    From 319fd3574390e5890c407d04a2052f0113fc4d1c Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 14 Nov 2016 17:21:14 +0100 Subject: [PATCH 29/50] [MIG] account_bank_statement_import_ofx: Migration to 10.0 * Remove the code that matches partners, which is wrong and cannot work * Better 'name' on bank statement * Move from models directory to wizard * Remove demo data to tests * Use latest version of ofxparse from github --- account_bank_statement_import_ofx/README.rst | 41 +++----- account_bank_statement_import_ofx/__init__.py | 2 +- .../__manifest__.py | 10 +- .../demo/demo_data.xml | 23 ----- .../models/account_bank_statement_import.py | 75 --------------- .../models/ofx.py | 40 -------- .../tests/test_import_bank_statement.py | 39 +++++--- .../view_account_bank_statement_import.xml | 2 +- .../{models => wizard}/__init__.py | 0 .../wizard/account_bank_statement_import.py | 94 +++++++++++++++++++ 10 files changed, 138 insertions(+), 188 deletions(-) delete mode 100644 account_bank_statement_import_ofx/demo/demo_data.xml delete mode 100644 account_bank_statement_import_ofx/models/account_bank_statement_import.py delete mode 100644 account_bank_statement_import_ofx/models/ofx.py rename account_bank_statement_import_ofx/{models => wizard}/__init__.py (100%) create mode 100644 account_bank_statement_import_ofx/wizard/account_bank_statement_import.py diff --git a/account_bank_statement_import_ofx/README.rst b/account_bank_statement_import_ofx/README.rst index cc06cc11..32622084 100644 --- a/account_bank_statement_import_ofx/README.rst +++ b/account_bank_statement_import_ofx/README.rst @@ -5,16 +5,10 @@ Import OFX Bank Statement ========================= -This module allows you to import the machine readable OFX Files in Odoo: they are parsed and stored in human readable format in -Accounting \ Bank and Cash \ Bank Statements. +This module adds support for the import of bank statements in `OFX format `_. -Bank Statements may be generated containing a subset of the OFX information (only those transaction lines that are required for the -creation of the Financial Accounting records). - -The module has been initiated by a backport of the new framework developed -by Odoo for V9 at its early stage. It's no more kept in sync with the V9 since -it has reach a stage where maintaining a pure backport of 9.0 in 8.0 is not -feasible anymore +Bank Statements may be generated containing a subset of the OFX information (only those transaction lines that are required for the +creation of the Financial Accounting records). Installation ============ @@ -23,20 +17,12 @@ The module requires one additional python lib: * `ofxparse `_ -Technical Note -============== - -this module is based on ofxparse python lib and overload some of its functions. - -* For the time being the default ofxparse lib available with - 'pip install ofxparse' do not manage correctly european amount that are - written with ',' and not with '.'. (For exemple, The Credit Cooperatif - French Bank provides OFX 1.0 with amounts written with coma) - -April, 27 2016: this problem has been fixed here: -https://github.com/jseutter/ofxparse/commit/283f89c3246ed3fedccc3ef5c96078b7d5b94579 -but it is not available in the pip lib for the time being. +Usage +===== +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/174/10.0 Known issues / Roadmap ====================== @@ -46,11 +32,10 @@ Known issues / Roadmap Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. - +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. Credits ======= @@ -77,4 +62,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py index a0fdc10f..02baef47 100644 --- a/account_bank_statement_import_ofx/__init__.py +++ b/account_bank_statement_import_ofx/__init__.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -from . import models +from . import wizard diff --git a/account_bank_statement_import_ofx/__manifest__.py b/account_bank_statement_import_ofx/__manifest__.py index 7e025449..df4f07f0 100644 --- a/account_bank_statement_import_ofx/__manifest__.py +++ b/account_bank_statement_import_ofx/__manifest__.py @@ -2,26 +2,22 @@ { 'name': 'Import OFX Bank Statement', 'category': 'Banking addons', - 'version': '9.0.0.0.0', + 'version': '10.0.1.0.0', 'license': 'AGPL-3', - 'author': 'OpenERP SA,' + 'author': 'Odoo SA,' + 'Akretion,' 'La Louve,' 'GRAP,' 'Odoo Community Association (OCA)', 'website': 'https://odoo-community.org/', 'depends': [ - 'l10n_generic_coa', 'account_bank_statement_import', ], 'data': [ 'views/view_account_bank_statement_import.xml', ], - 'demo': [ - 'demo/demo_data.xml', - ], 'external_dependencies': { 'python': ['ofxparse'], }, - 'auto_install': False, 'installable': True, } diff --git a/account_bank_statement_import_ofx/demo/demo_data.xml b/account_bank_statement_import_ofx/demo/demo_data.xml deleted file mode 100644 index 3a7a3520..00000000 --- a/account_bank_statement_import_ofx/demo/demo_data.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - Bank Journal - (test ofx) - OFX/%(range_year)s/ - no_gap - 4 - 1 - - - - - Bank Journal - (test ofx) - 123456 - TBNKOFX - bank - - - - - - diff --git a/account_bank_statement_import_ofx/models/account_bank_statement_import.py b/account_bank_statement_import_ofx/models/account_bank_statement_import.py deleted file mode 100644 index c05ee739..00000000 --- a/account_bank_statement_import_ofx/models/account_bank_statement_import.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- coding: utf-8 -*- - -import logging -import StringIO - -from openerp import api, models -from openerp.tools.translate import _ -from openerp.exceptions import Warning as UserError - -from .ofx import OfxParser, OfxParser_ok - -_logger = logging.getLogger(__name__) - - -class AccountBankStatementImport(models.TransientModel): - _inherit = 'account.bank.statement.import' - - @api.model - def _check_ofx(self, data_file): - if not OfxParser_ok: - return False - try: - ofx = OfxParser.parse(StringIO.StringIO(data_file)) - except Exception as e: - _logger.debug(e) - return False - return ofx - - @api.model - def _parse_file(self, data_file): - ofx = self._check_ofx(data_file) - if not ofx: - return super(AccountBankStatementImport, self)._parse_file( - data_file) - - transactions = [] - total_amt = 0.00 - try: - for transaction in ofx.account.statement.transactions: - # Since ofxparse doesn't provide account numbers, we'll have - # to find res.partner and res.partner.bank here - # (normal behavious is to provide 'account_number', which the - # generic module uses to find partner/bank) - bank_account_id = partner_id = False - banks = self.env['res.partner.bank'].search( - [('bank_name', '=', transaction.payee)], limit=1) - if banks: - bank_account = banks[0] - bank_account_id = bank_account.id - partner_id = bank_account.partner_id.id - vals_line = { - 'date': transaction.date, - 'name': transaction.payee + ( - transaction.memo and ': ' + transaction.memo or ''), - 'ref': transaction.id, - 'amount': transaction.amount, - 'unique_import_id': transaction.id, - 'bank_account_id': bank_account_id, - 'partner_id': partner_id, - } - total_amt += float(transaction.amount) - transactions.append(vals_line) - except Exception, e: - 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, - 'transactions': transactions, - 'balance_start': ofx.account.statement.balance, - 'balance_end_real': - float(ofx.account.statement.balance) + total_amt, - } - return ofx.account.statement.currency, ofx.account.number, [ - vals_bank_statement] diff --git a/account_bank_statement_import_ofx/models/ofx.py b/account_bank_statement_import_ofx/models/ofx.py deleted file mode 100644 index d7469383..00000000 --- a/account_bank_statement_import_ofx/models/ofx.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- - -import logging - -_logger = logging.getLogger(__name__) - -try: - from ofxparse import OfxParser as OfxParserOriginal - OfxParser_ok = True -except ImportError: - _logger.warn("ofxparse not found, OFX parsing disabled.") - OfxParserOriginal = object - OfxParser_ok = False - - -class OfxParser(OfxParserOriginal): - """ Custom changes in the OFX Parser. - """ - - @classmethod - def _tagToDecimal(self, tag): - tag.string = tag.string.replace(',', '.') - - @classmethod - def parseStatement(cls_, stmt_ofx): - """Amount with ',' replaced by '.' in the following tags : - //LEDGERBAL/BALAMT - """ - ledgerbal_tag = stmt_ofx.find('ledgerbal') - if hasattr(ledgerbal_tag, "contents"): - cls_._tagToDecimal(ledgerbal_tag.find('balamt')) - return super(OfxParser, cls_).parseStatement(stmt_ofx) - - @classmethod - def parseTransaction(cls_, txn_ofx): - """Amount with ',' replaced by '.' in the following tags : - //TRNAMT - """ - cls_._tagToDecimal(txn_ofx.find('trnamt')) - return super(OfxParser, cls_).parseTransaction(txn_ofx) diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 0efe690a..4b5c1e5b 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from openerp.tests.common import TransactionCase -from openerp.modules.module import get_module_resource +from odoo.tests.common import TransactionCase +from odoo.modules.module import get_module_resource class TestOfxFile(TransactionCase): @@ -10,26 +10,39 @@ class TestOfxFile(TransactionCase): def setUp(self): super(TestOfxFile, self).setUp() - self.statement_import_model = self.env['account.bank.statement.import'] - self.bank_statement_model = self.env['account.bank.statement'] + self.absi_model = self.env['account.bank.statement.import'] + self.abs_model = self.env['account.bank.statement'] + self.absl_model = self.env['account.bank.statement.line'] + cur = self.env.ref('base.USD') + self.env.ref('base.main_company').currency_id = cur.id + bank = self.env['res.partner.bank'].create({ + 'acc_number': '123456', + 'partner_id': self.env.ref('base.main_partner').id, + 'company_id': self.env.ref('base.main_company').id, + 'bank_id': self.env.ref('base.res_bank_1').id, + }) + self.env['account.journal'].create({ + 'name': 'Bank Journal TEST OFX', + 'code': 'BNK12', + 'type': 'bank', + 'bank_account_id': bank.id, + }) def test_ofx_file_import(self): ofx_file_path = get_module_resource( 'account_bank_statement_import_ofx', 'tests/test_ofx_file/', 'test_ofx.ofx') ofx_file = open(ofx_file_path, 'rb').read().encode('base64') - bank_statement = self.statement_import_model.create( + bank_statement = self.absi_model.create( dict(data_file=ofx_file)) bank_statement.import_file() - bank_st_record = self.bank_statement_model.search( - [('name', '=', '000000123')])[0] + bank_st_record = self.abs_model.search( + [('name', 'like', '123456')])[0] self.assertEquals(bank_st_record.balance_start, 2156.56) self.assertEquals(bank_st_record.balance_end_real, 1796.56) - line = bank_st_record.line_ids[0] - self.assertEquals(line.name, 'Agrolait') + line = self.absl_model.search([ + ('name', '=', 'Agrolait'), + ('statement_id', '=', bank_st_record.id)])[0] self.assertEquals(line.ref, '219378') - self.assertEquals(line.partner_id.id, self.ref('base.res_partner_2')) - self.assertEquals( - line.bank_account_id.id, - self.ref('account_bank_statement_import.ofx_partner_bank_1')) + self.assertEquals(line.date, '2013-08-24') diff --git a/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml b/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml index 3f0892fa..046ed1e4 100644 --- a/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml +++ b/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml @@ -1,4 +1,4 @@ - + account.bank.statement.import diff --git a/account_bank_statement_import_ofx/models/__init__.py b/account_bank_statement_import_ofx/wizard/__init__.py similarity index 100% rename from account_bank_statement_import_ofx/models/__init__.py rename to account_bank_statement_import_ofx/wizard/__init__.py diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py new file mode 100644 index 00000000..4835be7b --- /dev/null +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- + +import logging +import StringIO + +from odoo import api, models, fields, _ +from odoo.exceptions import UserError +from odoo.tools import float_is_zero + +_logger = logging.getLogger(__name__) + +try: + from ofxparse import OfxParser +except ImportError: + _logger.debug("ofxparse not found.") + OfxParser = None + + +class AccountBankStatementImport(models.TransientModel): + _inherit = 'account.bank.statement.import' + + @api.model + def _check_ofx(self, data_file): + if not OfxParser: + return False + try: + ofx = OfxParser.parse(StringIO.StringIO(data_file)) + except Exception as e: + _logger.debug(e) + return False + return ofx + + @api.model + def _prepare_ofx_transaction_line(self, transaction): + # since odoo 9, the account module defines a constraint + # on account.bank.statement.line: 'amount' must be != 0 + # But some banks have some transactions with amount=0 + # for bank charges that are offered, which blocks the import + precision = self.env['decimal.precision'].precision_get('Account') + if float_is_zero( + float(transaction.amount), precision_digits=precision): + return False + # Since ofxparse doesn't provide account numbers, + # we cannot provide the key 'bank_account_id', + # nor the key 'account_number' + # If you read odoo10/addons/account_bank_statement_import/ + # account_bank_statement_import.py, it's the only 2 keys + # we can provide to match a partner. + vals = { + 'date': transaction.date, + 'name': transaction.payee + ( + transaction.memo and ': ' + transaction.memo or ''), + 'ref': transaction.id, + 'amount': float(transaction.amount), + 'unique_import_id': transaction.id, + } + return vals + + @api.model + def _parse_file(self, data_file): + ofx = self._check_ofx(data_file) + if not ofx: + return super(AccountBankStatementImport, self)._parse_file( + data_file) + + transactions = [] + total_amt = 0.00 + start_date = end_date = False + try: + for transaction in ofx.account.statement.transactions: + vals = self._prepare_ofx_transaction_line(transaction) + if vals: + transactions.append(vals) + total_amt += vals['amount'] + tdate = fields.Date.to_string(vals['date']) + if not start_date or tdate < start_date: + start_date = tdate + if not end_date or tdate > end_date: + end_date = tdate + except Exception, e: + raise UserError(_( + "The following problem occurred during import. " + "The file might not be valid.\n\n %s") % e.message) + + vals_bank_statement = { + 'name': _('Account %s %s > %s') % ( + ofx.account.number, start_date, end_date), + 'transactions': transactions, + 'balance_start': ofx.account.statement.balance, + 'balance_end_real': + float(ofx.account.statement.balance) + total_amt, + } + return ofx.account.statement.currency, ofx.account.number, [ + vals_bank_statement] From 4fb715d4bdae76b96b8f279f44e9b8fecf172fc6 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Fri, 16 Dec 2016 19:13:46 -0500 Subject: [PATCH 30/50] OCA Transbot updated translations from Transifex --- account_bank_statement_import_ofx/i18n/fr.po | 31 ++++++++++++++----- .../i18n/lt_LT.po | 30 +++++++++++++----- account_bank_statement_import_ofx/i18n/nl.po | 30 +++++++++++++----- .../i18n/pt_BR.po | 30 +++++++++++++----- account_bank_statement_import_ofx/i18n/sl.po | 30 +++++++++++++----- 5 files changed, 111 insertions(+), 40 deletions(-) diff --git a/account_bank_statement_import_ofx/i18n/fr.po b/account_bank_statement_import_ofx/i18n/fr.po index 0125fee1..817837da 100644 --- a/account_bank_statement_import_ofx/i18n/fr.po +++ b/account_bank_statement_import_ofx/i18n/fr.po @@ -3,31 +3,46 @@ # * account_bank_statement_import_ofx # # Translators: -# zuher83 , 2015 +# OCA Transbot , 2016 +# leemannd , 2017 msgid "" msgstr "" -"Project-Id-Version: bank-statement-import (8.0)\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-24 21:51+0000\n" -"PO-Revision-Date: 2015-06-28 20:24+0000\n" -"Last-Translator: zuher83 \n" -"Language-Team: French (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/fr/)\n" +"POT-Creation-Date: 2016-12-15 03:36+0000\n" +"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"Last-Translator: leemannd , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 +#, python-format +msgid "Account %s %s > %s" +msgstr "Compte %s %s > %s" + #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importer Relevé Bancaire" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "Open Financial Exchange (.OFX Money)" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" -msgstr "Le problème suivant est survenu lors de l'importation. Le fichier n'est pas valide.\n\n%s" +msgstr "" +"Le problème suivant est survenu lors de l'importation. Le fichier n'est pas valide.\n" +"\n" +"%s" diff --git a/account_bank_statement_import_ofx/i18n/lt_LT.po b/account_bank_statement_import_ofx/i18n/lt_LT.po index 866c553c..58d99df1 100644 --- a/account_bank_statement_import_ofx/i18n/lt_LT.po +++ b/account_bank_statement_import_ofx/i18n/lt_LT.po @@ -3,31 +3,45 @@ # * account_bank_statement_import_ofx # # Translators: -# Arminas Grigonis , 2015 +# OCA Transbot , 2016 msgid "" msgstr "" -"Project-Id-Version: bank-statement-import (8.0)\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-24 21:51+0000\n" -"PO-Revision-Date: 2015-07-23 13:36+0000\n" -"Last-Translator: Arminas Grigonis \n" -"Language-Team: Lithuanian (Lithuania) (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/lt_LT/)\n" +"POT-Creation-Date: 2016-12-15 03:36+0000\n" +"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Lithuanian (Lithuania) (https://www.transifex.com/oca/teams/23907/lt_LT/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Language: lt_LT\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 +#, python-format +msgid "Account %s %s > %s" +msgstr "" + #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importuoti banko išrašą" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" -msgstr "Klaida. Failas gali būti sugadintas arba negaliojantis.\n\n %s" +msgstr "" +"Klaida. Failas gali būti sugadintas arba negaliojantis.\n" +"\n" +" %s" diff --git a/account_bank_statement_import_ofx/i18n/nl.po b/account_bank_statement_import_ofx/i18n/nl.po index 35482cc1..53d18666 100644 --- a/account_bank_statement_import_ofx/i18n/nl.po +++ b/account_bank_statement_import_ofx/i18n/nl.po @@ -3,31 +3,45 @@ # * account_bank_statement_import_ofx # # Translators: -# Erwin van der Ploeg , 2015 +# OCA Transbot , 2016 msgid "" msgstr "" -"Project-Id-Version: bank-statement-import (8.0)\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-24 21:51+0000\n" -"PO-Revision-Date: 2015-08-17 19:03+0000\n" -"Last-Translator: Erwin van der Ploeg \n" -"Language-Team: Dutch (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/nl/)\n" +"POT-Creation-Date: 2016-12-15 03:36+0000\n" +"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Language: nl\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 +#, python-format +msgid "Account %s %s > %s" +msgstr "" + #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importeer bankafschrift" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" -msgstr "Het volgende probleem is opgetreden tijdens de import. Het bestand is waarschijnlijk niet juist.\n\n%s" +msgstr "" +"Het volgende probleem is opgetreden tijdens de import. Het bestand is waarschijnlijk niet juist.\n" +"\n" +"%s" diff --git a/account_bank_statement_import_ofx/i18n/pt_BR.po b/account_bank_statement_import_ofx/i18n/pt_BR.po index 12bde786..05c78166 100644 --- a/account_bank_statement_import_ofx/i18n/pt_BR.po +++ b/account_bank_statement_import_ofx/i18n/pt_BR.po @@ -3,31 +3,45 @@ # * account_bank_statement_import_ofx # # Translators: -# danimaribeiro , 2015 +# OCA Transbot , 2016 msgid "" msgstr "" -"Project-Id-Version: bank-statement-import (8.0)\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-10-09 09:23+0000\n" -"PO-Revision-Date: 2015-10-09 00:24+0000\n" -"Last-Translator: danimaribeiro \n" -"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/pt_BR/)\n" +"POT-Creation-Date: 2016-12-15 03:36+0000\n" +"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 +#, python-format +msgid "Account %s %s > %s" +msgstr "" + #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importar extrato bancário" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" -msgstr "O seguinte problema ocorreu durante a importação. O arquivo não deve ser válido.\n\n%s" +msgstr "" +"O seguinte problema ocorreu durante a importação. O arquivo não deve ser válido.\n" +"\n" +"%s" diff --git a/account_bank_statement_import_ofx/i18n/sl.po b/account_bank_statement_import_ofx/i18n/sl.po index de6cae28..9df10801 100644 --- a/account_bank_statement_import_ofx/i18n/sl.po +++ b/account_bank_statement_import_ofx/i18n/sl.po @@ -3,31 +3,45 @@ # * account_bank_statement_import_ofx # # Translators: -# Matjaž Mozetič , 2015 +# OCA Transbot , 2016 msgid "" msgstr "" -"Project-Id-Version: bank-statement-import (8.0)\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-24 21:51+0000\n" -"PO-Revision-Date: 2015-06-28 05:23+0000\n" -"Last-Translator: Matjaž Mozetič \n" -"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/sl/)\n" +"POT-Creation-Date: 2016-12-15 03:36+0000\n" +"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Language: sl\n" "Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 +#, python-format +msgid "Account %s %s > %s" +msgstr "" + #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Uvoz bančnega izpiska" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" -msgstr "Med uvozom je prišlo do težav. Datoteka ni veljavna.\n\n %s" +msgstr "" +"Med uvozom je prišlo do težav. Datoteka ni veljavna.\n" +"\n" +" %s" From ed2169e193c5b7f74864bcbabf4583a15068464a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 18 Mar 2017 17:41:20 +0100 Subject: [PATCH 31/50] [10.0] OFX: fix start/end balance (#90) Remove start/end dates in name of statement, because it's better to have it via 2 computed fields --- .../tests/test_import_bank_statement.py | 4 ++-- .../wizard/account_bank_statement_import.py | 17 +++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 4b5c1e5b..4f01a6ac 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -38,8 +38,8 @@ class TestOfxFile(TransactionCase): bank_statement.import_file() bank_st_record = self.abs_model.search( [('name', 'like', '123456')])[0] - self.assertEquals(bank_st_record.balance_start, 2156.56) - self.assertEquals(bank_st_record.balance_end_real, 1796.56) + self.assertEquals(bank_st_record.balance_start, 2516.56) + self.assertEquals(bank_st_record.balance_end_real, 2156.56) line = self.absl_model.search([ ('name', '=', 'Agrolait'), diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py index 4835be7b..e439bba0 100644 --- a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -3,7 +3,7 @@ import logging import StringIO -from odoo import api, models, fields, _ +from odoo import api, models, _ from odoo.exceptions import UserError from odoo.tools import float_is_zero @@ -65,30 +65,23 @@ class AccountBankStatementImport(models.TransientModel): transactions = [] total_amt = 0.00 - start_date = end_date = False try: for transaction in ofx.account.statement.transactions: vals = self._prepare_ofx_transaction_line(transaction) if vals: transactions.append(vals) total_amt += vals['amount'] - tdate = fields.Date.to_string(vals['date']) - if not start_date or tdate < start_date: - start_date = tdate - if not end_date or tdate > end_date: - end_date = tdate except Exception, e: raise UserError(_( "The following problem occurred during import. " "The file might not be valid.\n\n %s") % e.message) + balance = float(ofx.account.statement.balance) vals_bank_statement = { - 'name': _('Account %s %s > %s') % ( - ofx.account.number, start_date, end_date), + 'name': ofx.account.number, 'transactions': transactions, - 'balance_start': ofx.account.statement.balance, - 'balance_end_real': - float(ofx.account.statement.balance) + total_amt, + 'balance_start': balance - total_amt, + 'balance_end_real': balance, } return ofx.account.statement.currency, ofx.account.number, [ vals_bank_statement] From 6e49209371308ff53f613474149bfab696a7b34e Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Fri, 24 Mar 2017 21:10:43 -0400 Subject: [PATCH 32/50] OCA Transbot updated translations from Transifex --- account_bank_statement_import_ofx/i18n/de.po | 42 +++++++++++++++++++ account_bank_statement_import_ofx/i18n/fi.po | 38 +++++++++++++++++ account_bank_statement_import_ofx/i18n/fr.po | 12 ++---- .../i18n/fr_CH.po | 38 +++++++++++++++++ account_bank_statement_import_ofx/i18n/gl.po | 38 +++++++++++++++++ .../i18n/lt_LT.po | 12 ++---- .../i18n/nb_NO.po | 38 +++++++++++++++++ account_bank_statement_import_ofx/i18n/nl.po | 12 ++---- .../i18n/pt_BR.po | 12 ++---- .../i18n/pt_PT.po | 38 +++++++++++++++++ account_bank_statement_import_ofx/i18n/sl.po | 12 ++---- 11 files changed, 247 insertions(+), 45 deletions(-) create mode 100644 account_bank_statement_import_ofx/i18n/de.po create mode 100644 account_bank_statement_import_ofx/i18n/fi.po create mode 100644 account_bank_statement_import_ofx/i18n/fr_CH.po create mode 100644 account_bank_statement_import_ofx/i18n/gl.po create mode 100644 account_bank_statement_import_ofx/i18n/nb_NO.po create mode 100644 account_bank_statement_import_ofx/i18n/pt_PT.po diff --git a/account_bank_statement_import_ofx/i18n/de.po b/account_bank_statement_import_ofx/i18n/de.po new file mode 100644 index 00000000..bf74b0ca --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/de.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# OCA Transbot , 2017 +# Niki Waibel , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" +"Last-Translator: Niki Waibel , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Kontoauszug importieren" + +#. module: account_bank_statement_import_ofx +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "Open Financial Exchange (.OFX Money)" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" +"Das folgende Problem ist beim Importieren aufgetreten. Die Datei ist dürfte ungültig sein.\n" +"\n" +"%s" diff --git a/account_bank_statement_import_ofx/i18n/fi.po b/account_bank_statement_import_ofx/i18n/fi.po new file mode 100644 index 00000000..f573e12e --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/fi.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fi\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Tuo pankkiaineisto" + +#. module: account_bank_statement_import_ofx +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/fr.po b/account_bank_statement_import_ofx/i18n/fr.po index 817837da..6f84da84 100644 --- a/account_bank_statement_import_ofx/i18n/fr.po +++ b/account_bank_statement_import_ofx/i18n/fr.po @@ -9,8 +9,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-15 03:36+0000\n" -"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: leemannd , 2017\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "MIME-Version: 1.0\n" @@ -19,12 +19,6 @@ msgstr "" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 -#, python-format -msgid "Account %s %s > %s" -msgstr "Compte %s %s > %s" - #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" @@ -36,7 +30,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "Open Financial Exchange (.OFX Money)" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/fr_CH.po b/account_bank_statement_import_ofx/i18n/fr_CH.po new file mode 100644 index 00000000..147e8886 --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/fr_CH.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: French (Switzerland) (https://www.transifex.com/oca/teams/23907/fr_CH/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr_CH\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importer Relevé" + +#. module: account_bank_statement_import_ofx +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/gl.po b/account_bank_statement_import_ofx/i18n/gl.po new file mode 100644 index 00000000..d8ec0d45 --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/gl.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Galician (https://www.transifex.com/oca/teams/23907/gl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: gl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importar extracto bancario" + +#. module: account_bank_statement_import_ofx +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/lt_LT.po b/account_bank_statement_import_ofx/i18n/lt_LT.po index 58d99df1..297d15c8 100644 --- a/account_bank_statement_import_ofx/i18n/lt_LT.po +++ b/account_bank_statement_import_ofx/i18n/lt_LT.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-15 03:36+0000\n" -"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: Lithuanian (Lithuania) (https://www.transifex.com/oca/teams/23907/lt_LT/)\n" "MIME-Version: 1.0\n" @@ -18,12 +18,6 @@ msgstr "" "Language: lt_LT\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n" -#. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 -#, python-format -msgid "Account %s %s > %s" -msgstr "" - #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" @@ -35,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/nb_NO.po b/account_bank_statement_import_ofx/i18n/nb_NO.po new file mode 100644 index 00000000..e81a792c --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/nb_NO.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Norwegian Bokmål (Norway) (https://www.transifex.com/oca/teams/23907/nb_NO/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nb_NO\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importer bankutsagn" + +#. module: account_bank_statement_import_ofx +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/nl.po b/account_bank_statement_import_ofx/i18n/nl.po index 53d18666..74b421b7 100644 --- a/account_bank_statement_import_ofx/i18n/nl.po +++ b/account_bank_statement_import_ofx/i18n/nl.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-15 03:36+0000\n" -"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" "MIME-Version: 1.0\n" @@ -18,12 +18,6 @@ msgstr "" "Language: nl\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 -#, python-format -msgid "Account %s %s > %s" -msgstr "" - #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" @@ -35,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/pt_BR.po b/account_bank_statement_import_ofx/i18n/pt_BR.po index 05c78166..7e5f1912 100644 --- a/account_bank_statement_import_ofx/i18n/pt_BR.po +++ b/account_bank_statement_import_ofx/i18n/pt_BR.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-15 03:36+0000\n" -"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" "MIME-Version: 1.0\n" @@ -18,12 +18,6 @@ msgstr "" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 -#, python-format -msgid "Account %s %s > %s" -msgstr "" - #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" @@ -35,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/pt_PT.po b/account_bank_statement_import_ofx/i18n/pt_PT.po new file mode 100644 index 00000000..4d00797f --- /dev/null +++ b/account_bank_statement_import_ofx/i18n/pt_PT.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_ofx +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Portuguese (Portugal) (https://www.transifex.com/oca/teams/23907/pt_PT/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_PT\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_ofx +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importar Extrato Bancário" + +#. module: account_bank_statement_import_ofx +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/sl.po b/account_bank_statement_import_ofx/i18n/sl.po index 9df10801..710065ed 100644 --- a/account_bank_statement_import_ofx/i18n/sl.po +++ b/account_bank_statement_import_ofx/i18n/sl.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-15 03:36+0000\n" -"PO-Revision-Date: 2016-12-15 03:36+0000\n" +"POT-Creation-Date: 2017-03-19 03:39+0000\n" +"PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" "MIME-Version: 1.0\n" @@ -18,12 +18,6 @@ msgstr "" "Language: sl\n" "Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" -#. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:86 -#, python-format -msgid "Account %s %s > %s" -msgstr "" - #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" @@ -35,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" From ca15dd9df99b9b1b0a517ea97acd56a0f82b72b5 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 29 Mar 2017 16:26:52 +0200 Subject: [PATCH 33/50] Remove the auto-delete lines with 0 amount (feature now provided by the module account_bank_statement_import) --- .../wizard/account_bank_statement_import.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py index e439bba0..50ba61f4 100644 --- a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -5,7 +5,6 @@ import StringIO from odoo import api, models, _ from odoo.exceptions import UserError -from odoo.tools import float_is_zero _logger = logging.getLogger(__name__) @@ -32,14 +31,6 @@ class AccountBankStatementImport(models.TransientModel): @api.model def _prepare_ofx_transaction_line(self, transaction): - # since odoo 9, the account module defines a constraint - # on account.bank.statement.line: 'amount' must be != 0 - # But some banks have some transactions with amount=0 - # for bank charges that are offered, which blocks the import - precision = self.env['decimal.precision'].precision_get('Account') - if float_is_zero( - float(transaction.amount), precision_digits=precision): - return False # Since ofxparse doesn't provide account numbers, # we cannot provide the key 'bank_account_id', # nor the key 'account_number' From 6be6936009784f0d2defd1f02fa2cecce05a04c1 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 11 Apr 2017 23:01:16 +0200 Subject: [PATCH 34/50] [FIX] crash in account_bank_statement_save_file --- .../wizard/account_bank_statement_import.py | 1 - 1 file changed, 1 deletion(-) diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py index 50ba61f4..e063d455 100644 --- a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -47,7 +47,6 @@ class AccountBankStatementImport(models.TransientModel): } return vals - @api.model def _parse_file(self, data_file): ofx = self._check_ofx(data_file) if not ofx: From 3ff0c6a99743a9d89da54402a882ebefff56efb8 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Mon, 1 May 2017 16:50:16 +0200 Subject: [PATCH 35/50] OCA Transbot updated translations from Transifex --- account_bank_statement_import_ofx/i18n/de.po | 9 ++++----- account_bank_statement_import_ofx/i18n/fr.po | 9 ++++----- account_bank_statement_import_ofx/i18n/lt_LT.po | 6 +++--- account_bank_statement_import_ofx/i18n/nl.po | 6 +++--- account_bank_statement_import_ofx/i18n/pt_BR.po | 12 ++++++------ account_bank_statement_import_ofx/i18n/sl.po | 6 +++--- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/account_bank_statement_import_ofx/i18n/de.po b/account_bank_statement_import_ofx/i18n/de.po index bf74b0ca..d1786931 100644 --- a/account_bank_statement_import_ofx/i18n/de.po +++ b/account_bank_statement_import_ofx/i18n/de.po @@ -4,14 +4,13 @@ # # Translators: # OCA Transbot , 2017 -# Niki Waibel , 2017 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-19 03:39+0000\n" -"PO-Revision-Date: 2017-03-19 03:39+0000\n" -"Last-Translator: Niki Waibel , 2017\n" +"POT-Creation-Date: 2017-04-11 21:55+0000\n" +"PO-Revision-Date: 2017-04-11 21:55+0000\n" +"Last-Translator: OCA Transbot , 2017\n" "Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -30,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "Open Financial Exchange (.OFX Money)" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/fr.po b/account_bank_statement_import_ofx/i18n/fr.po index 6f84da84..9ce95eee 100644 --- a/account_bank_statement_import_ofx/i18n/fr.po +++ b/account_bank_statement_import_ofx/i18n/fr.po @@ -4,14 +4,13 @@ # # Translators: # OCA Transbot , 2016 -# leemannd , 2017 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-19 03:39+0000\n" -"PO-Revision-Date: 2017-03-19 03:39+0000\n" -"Last-Translator: leemannd , 2017\n" +"POT-Creation-Date: 2017-04-11 21:55+0000\n" +"PO-Revision-Date: 2017-04-11 21:55+0000\n" +"Last-Translator: OCA Transbot , 2016\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -30,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "Open Financial Exchange (.OFX Money)" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/lt_LT.po b/account_bank_statement_import_ofx/i18n/lt_LT.po index 297d15c8..dd03ac34 100644 --- a/account_bank_statement_import_ofx/i18n/lt_LT.po +++ b/account_bank_statement_import_ofx/i18n/lt_LT.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-19 03:39+0000\n" -"PO-Revision-Date: 2017-03-19 03:39+0000\n" +"POT-Creation-Date: 2017-04-11 21:55+0000\n" +"PO-Revision-Date: 2017-04-11 21:55+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: Lithuanian (Lithuania) (https://www.transifex.com/oca/teams/23907/lt_LT/)\n" "MIME-Version: 1.0\n" @@ -29,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/nl.po b/account_bank_statement_import_ofx/i18n/nl.po index 74b421b7..bef900f6 100644 --- a/account_bank_statement_import_ofx/i18n/nl.po +++ b/account_bank_statement_import_ofx/i18n/nl.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-19 03:39+0000\n" -"PO-Revision-Date: 2017-03-19 03:39+0000\n" +"POT-Creation-Date: 2017-04-11 21:55+0000\n" +"PO-Revision-Date: 2017-04-11 21:55+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" "MIME-Version: 1.0\n" @@ -29,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/pt_BR.po b/account_bank_statement_import_ofx/i18n/pt_BR.po index 7e5f1912..325d5d24 100644 --- a/account_bank_statement_import_ofx/i18n/pt_BR.po +++ b/account_bank_statement_import_ofx/i18n/pt_BR.po @@ -3,14 +3,14 @@ # * account_bank_statement_import_ofx # # Translators: -# OCA Transbot , 2016 +# OCA Transbot , 2017 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-19 03:39+0000\n" -"PO-Revision-Date: 2017-03-19 03:39+0000\n" -"Last-Translator: OCA Transbot , 2016\n" +"POT-Creation-Date: 2017-11-21 01:42+0000\n" +"PO-Revision-Date: 2017-11-21 01:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" "Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -21,7 +21,7 @@ msgstr "" #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import msgid "Import Bank Statement" -msgstr "Importar extrato bancário" +msgstr "Importar Extrato Bancário" #. module: account_bank_statement_import_ofx #: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form @@ -29,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/sl.po b/account_bank_statement_import_ofx/i18n/sl.po index 710065ed..f906c954 100644 --- a/account_bank_statement_import_ofx/i18n/sl.po +++ b/account_bank_statement_import_ofx/i18n/sl.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-19 03:39+0000\n" -"PO-Revision-Date: 2017-03-19 03:39+0000\n" +"POT-Creation-Date: 2017-04-11 21:55+0000\n" +"PO-Revision-Date: 2017-04-11 21:55+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" "MIME-Version: 1.0\n" @@ -29,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" From 8e22f27b5b816b178e3da3bb62684ce8931189c4 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Thu, 18 Jan 2018 14:34:51 +0100 Subject: [PATCH 36/50] [MIG] migrate account_bank_statement_import_ofx to V11 - add #136 patch --- account_bank_statement_import_ofx/README.rst | 3 +- account_bank_statement_import_ofx/__init__.py | 1 - .../__manifest__.py | 4 +- .../tests/__init__.py | 1 - .../tests/test_import_bank_statement.py | 50 +++++++-- .../tests/test_ofx_file/test_ofx_iban.ofx | 101 ++++++++++++++++++ .../tests/test_ofx_file/test_ofx_wrong.ofx | 100 +++++++++++++++++ .../wizard/__init__.py | 1 - .../wizard/account_bank_statement_import.py | 26 ++++- 9 files changed, 270 insertions(+), 17 deletions(-) create mode 100644 account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx_iban.ofx create mode 100644 account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx_wrong.ofx diff --git a/account_bank_statement_import_ofx/README.rst b/account_bank_statement_import_ofx/README.rst index 32622084..84354309 100644 --- a/account_bank_statement_import_ofx/README.rst +++ b/account_bank_statement_import_ofx/README.rst @@ -22,7 +22,7 @@ Usage .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/174/10.0 + :target: https://runbot.odoo-community.org/runbot/174/11.0 Known issues / Roadmap ====================== @@ -48,6 +48,7 @@ Contributors * Laurent Mignon * Ronald Portier * Sylvain LE GAL +* Nicolas JEUDY Maintainer ---------- diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py index 02baef47..40272379 100644 --- a/account_bank_statement_import_ofx/__init__.py +++ b/account_bank_statement_import_ofx/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import wizard diff --git a/account_bank_statement_import_ofx/__manifest__.py b/account_bank_statement_import_ofx/__manifest__.py index df4f07f0..d4305e7a 100644 --- a/account_bank_statement_import_ofx/__manifest__.py +++ b/account_bank_statement_import_ofx/__manifest__.py @@ -1,13 +1,13 @@ -# -*- coding: utf-8 -*- { 'name': 'Import OFX Bank Statement', 'category': 'Banking addons', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'license': 'AGPL-3', 'author': 'Odoo SA,' 'Akretion,' 'La Louve,' 'GRAP,' + 'Nicolas JEUDY,' 'Odoo Community Association (OCA)', 'website': 'https://odoo-community.org/', 'depends': [ diff --git a/account_bank_statement_import_ofx/tests/__init__.py b/account_bank_statement_import_ofx/tests/__init__.py index 9ce25a7f..bb3456ae 100644 --- a/account_bank_statement_import_ofx/tests/__init__.py +++ b/account_bank_statement_import_ofx/tests/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import test_import_bank_statement diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 4f01a6ac..095dd709 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- from odoo.tests.common import TransactionCase from odoo.modules.module import get_module_resource +import base64 class TestOfxFile(TransactionCase): @@ -12,6 +12,7 @@ class TestOfxFile(TransactionCase): super(TestOfxFile, self).setUp() self.absi_model = self.env['account.bank.statement.import'] self.abs_model = self.env['account.bank.statement'] + self.j_model = self.env['account.journal'] self.absl_model = self.env['account.bank.statement.line'] cur = self.env.ref('base.USD') self.env.ref('base.main_company').currency_id = cur.id @@ -20,29 +21,66 @@ class TestOfxFile(TransactionCase): 'partner_id': self.env.ref('base.main_partner').id, 'company_id': self.env.ref('base.main_company').id, 'bank_id': self.env.ref('base.res_bank_1').id, - }) + }) self.env['account.journal'].create({ 'name': 'Bank Journal TEST OFX', 'code': 'BNK12', 'type': 'bank', 'bank_account_id': bank.id, - }) + }) + + bank_iban_ofx = self.env['res.partner.bank'].create({ + 'acc_number': 'FR7630001007941234567890185', + 'partner_id': self.env.ref('base.main_partner').id, + 'company_id': self.env.ref('base.main_company').id, + 'bank_id': self.env.ref('base.res_bank_1').id, + }) + + self.env['account.journal'].create({ + 'name': 'FR7630001007941234567890185', + 'code': 'BNK13', + 'type': 'bank', + 'bank_account_id': bank_iban_ofx.id, + }) + + def test_wrong_ofx_file_import(self): + ofx_file_path = get_module_resource( + 'account_bank_statement_import_ofx', + 'tests/test_ofx_file/', 'test_ofx_wrong.ofx') + ofx_file_wrong = base64.b64encode(open(ofx_file_path, 'rb').read()) + bank_statement = self.absi_model.create( + dict(data_file=ofx_file_wrong)) + self.assertFalse(bank_statement._check_ofx(data_file=ofx_file_wrong)) def test_ofx_file_import(self): ofx_file_path = get_module_resource( 'account_bank_statement_import_ofx', 'tests/test_ofx_file/', 'test_ofx.ofx') - ofx_file = open(ofx_file_path, 'rb').read().encode('base64') + ofx_file = base64.b64encode(open(ofx_file_path, 'rb').read()) bank_statement = self.absi_model.create( dict(data_file=ofx_file)) bank_statement.import_file() bank_st_record = self.abs_model.search( [('name', 'like', '123456')])[0] - self.assertEquals(bank_st_record.balance_start, 2516.56) - self.assertEquals(bank_st_record.balance_end_real, 2156.56) + self.assertEqual(bank_st_record.balance_start, 2516.56) + self.assertEqual(bank_st_record.balance_end_real, 2156.56) line = self.absl_model.search([ ('name', '=', 'Agrolait'), ('statement_id', '=', bank_st_record.id)])[0] self.assertEquals(line.ref, '219378') self.assertEquals(line.date, '2013-08-24') + + def test_check_journal_bank_account(self): + ofx_file_path = get_module_resource( + 'account_bank_statement_import_ofx', + 'tests/test_ofx_file/', 'test_ofx_iban.ofx') + ofx_file = base64.b64encode(open(ofx_file_path, 'rb').read()) + bank_st = self.absi_model.create( + dict(data_file=ofx_file)) + journal_iban_ofx = self.j_model.search([ + ('name', '=', 'FR7630001007941234567890185')]) + res = bank_st._check_journal_bank_account(journal_iban_ofx, + '12345678901') + self.assertTrue(res) + bank_st.with_context(journal_id=journal_iban_ofx.id).import_file() diff --git a/account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx_iban.ofx b/account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx_iban.ofx new file mode 100644 index 00000000..99c01618 --- /dev/null +++ b/account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx_iban.ofx @@ -0,0 +1,101 @@ + + + + + + + 0 + INFO + + 20130831165153.000[-8:PST] + ENG + + + + + 0 + + 0 + INFO + + + USD + + 30001 + 00794 + 12345678901 + CHECKING + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -80 + 219378 + Agrolait + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -90 + 219379 + China Export + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -100 + 219380 + Axelor Scuba + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -90 + 219381 + China Scuba + + + + 2156.56 + 20130831165153 + + + + + + + 0 + + 0 + INFO + + + USD + + 123412341234 + + + + + -562.00 + 20130831165153 + + + + + diff --git a/account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx_wrong.ofx b/account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx_wrong.ofx new file mode 100644 index 00000000..b9e64a39 --- /dev/null +++ b/account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx_wrong.ofx @@ -0,0 +1,100 @@ + + + + + + + 0 + INFO + + 20130831165153.000[-8:PST] + ENG + + + + + 0 + + 0 + INFO + + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -80 + 219378 + Agrolait + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + + China Export + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -100 + 219380 + Axelor Scuba + + + + 20130801 + 20130831165153.000[-8:PST] + + POS + 20130824080000 + -90 + 219381 + China Scuba + + + + 2156.56 + 20130831165153 + + + + + + + 0 + + 0 + INFO + + + USD + + 123412341234 + + + + + -562.00 + 20130831165153 + + + + + diff --git a/account_bank_statement_import_ofx/wizard/__init__.py b/account_bank_statement_import_ofx/wizard/__init__.py index 5dfe830f..7dafcd16 100644 --- a/account_bank_statement_import_ofx/wizard/__init__.py +++ b/account_bank_statement_import_ofx/wizard/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import account_bank_statement_import diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py index e063d455..4258759b 100644 --- a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -1,10 +1,10 @@ -# -*- coding: utf-8 -*- - import logging -import StringIO +import io from odoo import api, models, _ from odoo.exceptions import UserError +from odoo.addons.base_iban.models.res_partner_bank import _map_iban_template +from odoo.addons.base_iban.models.res_partner_bank import validate_iban _logger = logging.getLogger(__name__) @@ -18,12 +18,28 @@ except ImportError: class AccountBankStatementImport(models.TransientModel): _inherit = 'account.bank.statement.import' + def _check_journal_bank_account(self, journal, account_number): + res = super( + AccountBankStatementImport, self + )._check_journal_bank_account(journal, account_number) + if not res: + e_acc_num = journal.bank_account_id.sanitized_acc_number + e_acc_num = e_acc_num.replace(" ", "") + validate_iban(e_acc_num) + country_code = e_acc_num[:2].lower() + iban_template = _map_iban_template[country_code].replace( + " ", "") + e_acc_num = "".join( + [c for c, t in zip(e_acc_num, iban_template) if t == "C"]) + res = (e_acc_num == account_number) + return res + @api.model def _check_ofx(self, data_file): if not OfxParser: return False try: - ofx = OfxParser.parse(StringIO.StringIO(data_file)) + ofx = OfxParser.parse(io.StringIO(data_file.decode('utf-8'))) except Exception as e: _logger.debug(e) return False @@ -61,7 +77,7 @@ class AccountBankStatementImport(models.TransientModel): if vals: transactions.append(vals) total_amt += vals['amount'] - except Exception, e: + except Exception as e: raise UserError(_( "The following problem occurred during import. " "The file might not be valid.\n\n %s") % e.message) From 99c6edad52e40bc1f2af17d8cbf4992a874b5aa3 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Thu, 11 Oct 2018 20:42:01 +0000 Subject: [PATCH 37/50] [UPD] Update account_bank_statement_import_ofx.pot --- .../i18n/account_bank_statement_import_ofx.pot | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot b/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot index 1c67dafa..7c267d20 100644 --- a/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot +++ b/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot @@ -4,10 +4,8 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-06-08 09:11+0000\n" -"PO-Revision-Date: 2015-06-08 09:11+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,7 +19,12 @@ msgid "Import Bank Statement" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "The following problem occurred during import. The file might not be valid.\n" "\n" From 2b73ef3b18eebcdb90d8a32ba1f08c7f1bf2de47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faure-Lacroix?= Date: Thu, 18 Oct 2018 00:55:39 +0300 Subject: [PATCH 38/50] [11.0 BUGFIX] Pass bytes to Ofxparse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ofx files have the correct charset inside their headers and trying to convert the file to StringIO using a particular encoding is subject to failures when the file isn't exactly an ascii file. For example a file encoded with CP1252 with accents on letters like é or è will not be parser as utf-8 and will fail to load. Also since OfxParse is supposed to receive a file handle, it is correctly reading the file header and choosing the appropriate charset to read the rest of the file. For this reason, pass the bytes as a ByteIO that doesn't care about the encoding. --- .../wizard/account_bank_statement_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py index 4258759b..8944add3 100644 --- a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -39,7 +39,7 @@ class AccountBankStatementImport(models.TransientModel): if not OfxParser: return False try: - ofx = OfxParser.parse(io.StringIO(data_file.decode('utf-8'))) + ofx = OfxParser.parse(io.BytesIO(data_file)) except Exception as e: _logger.debug(e) return False From 7ac59bd6cd5775fb7075a66c357ce3c5f746a120 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sun, 2 Dec 2018 02:33:37 +0000 Subject: [PATCH 39/50] Update translation files Updated by Update PO files to match POT (msgmerge) hook in Weblate. --- account_bank_statement_import_ofx/i18n/de.po | 9 +++++---- account_bank_statement_import_ofx/i18n/es.po | 14 ++++++++++---- account_bank_statement_import_ofx/i18n/fi.po | 6 +++--- account_bank_statement_import_ofx/i18n/fr.po | 9 +++++---- account_bank_statement_import_ofx/i18n/fr_CH.po | 9 +++++---- account_bank_statement_import_ofx/i18n/gl.po | 6 +++--- account_bank_statement_import_ofx/i18n/lt_LT.po | 12 +++++++----- account_bank_statement_import_ofx/i18n/nb_NO.po | 9 +++++---- account_bank_statement_import_ofx/i18n/nl.po | 9 +++++---- account_bank_statement_import_ofx/i18n/pt_BR.po | 12 +++++++----- account_bank_statement_import_ofx/i18n/pt_PT.po | 9 +++++---- account_bank_statement_import_ofx/i18n/sl.po | 9 +++++---- 12 files changed, 65 insertions(+), 48 deletions(-) diff --git a/account_bank_statement_import_ofx/i18n/de.po b/account_bank_statement_import_ofx/i18n/de.po index d1786931..3f881f90 100644 --- a/account_bank_statement_import_ofx/i18n/de.po +++ b/account_bank_statement_import_ofx/i18n/de.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2017 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-04-11 21:55+0000\n" "Last-Translator: OCA Transbot , 2017\n" "Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: account_bank_statement_import_ofx @@ -29,13 +29,14 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "Open Financial Exchange (.OFX Money)" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" msgstr "" -"Das folgende Problem ist beim Importieren aufgetreten. Die Datei ist dürfte ungültig sein.\n" +"Das folgende Problem ist beim Importieren aufgetreten. Die Datei ist dürfte " +"ungültig sein.\n" "\n" "%s" diff --git a/account_bank_statement_import_ofx/i18n/es.po b/account_bank_statement_import_ofx/i18n/es.po index 174f8f51..0e5c3303 100644 --- a/account_bank_statement_import_ofx/i18n/es.po +++ b/account_bank_statement_import_ofx/i18n/es.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: msgid "" msgstr "" @@ -10,11 +10,12 @@ msgstr "" "POT-Creation-Date: 2015-07-24 21:51+0000\n" "PO-Revision-Date: 2015-05-29 00:50+0000\n" "Last-Translator: OCA Transbot \n" -"Language-Team: Spanish (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/es/)\n" +"Language-Team: Spanish (http://www.transifex.com/oca/OCA-bank-statement-" +"import-8-0/language/es/)\n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: es\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: account_bank_statement_import_ofx @@ -23,7 +24,12 @@ msgid "Import Bank Statement" msgstr "Importar extracto bancario" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py:67 +#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +msgid "Open Financial Exchange (.OFX Money)" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/fi.po b/account_bank_statement_import_ofx/i18n/fi.po index f573e12e..6617a1d9 100644 --- a/account_bank_statement_import_ofx/i18n/fi.po +++ b/account_bank_statement_import_ofx/i18n/fi.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2017 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: OCA Transbot , 2017\n" "Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"Language: fi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: fi\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: account_bank_statement_import_ofx @@ -29,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/fr.po b/account_bank_statement_import_ofx/i18n/fr.po index 9ce95eee..3e504e99 100644 --- a/account_bank_statement_import_ofx/i18n/fr.po +++ b/account_bank_statement_import_ofx/i18n/fr.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2016 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-04-11 21:55+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: account_bank_statement_import_ofx @@ -29,13 +29,14 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "Open Financial Exchange (.OFX Money)" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" msgstr "" -"Le problème suivant est survenu lors de l'importation. Le fichier n'est pas valide.\n" +"Le problème suivant est survenu lors de l'importation. Le fichier n'est pas " +"valide.\n" "\n" "%s" diff --git a/account_bank_statement_import_ofx/i18n/fr_CH.po b/account_bank_statement_import_ofx/i18n/fr_CH.po index 147e8886..f13f1429 100644 --- a/account_bank_statement_import_ofx/i18n/fr_CH.po +++ b/account_bank_statement_import_ofx/i18n/fr_CH.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-03-19 03:39+0000\n" "PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: OCA Transbot , 2017\n" -"Language-Team: French (Switzerland) (https://www.transifex.com/oca/teams/23907/fr_CH/)\n" +"Language-Team: French (Switzerland) (https://www.transifex.com/oca/" +"teams/23907/fr_CH/)\n" +"Language: fr_CH\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: fr_CH\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: account_bank_statement_import_ofx @@ -29,7 +30,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/gl.po b/account_bank_statement_import_ofx/i18n/gl.po index d8ec0d45..9147efad 100644 --- a/account_bank_statement_import_ofx/i18n/gl.po +++ b/account_bank_statement_import_ofx/i18n/gl.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2017 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: OCA Transbot , 2017\n" "Language-Team: Galician (https://www.transifex.com/oca/teams/23907/gl/)\n" +"Language: gl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: gl\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: account_bank_statement_import_ofx @@ -29,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/lt_LT.po b/account_bank_statement_import_ofx/i18n/lt_LT.po index dd03ac34..45d0b47d 100644 --- a/account_bank_statement_import_ofx/i18n/lt_LT.po +++ b/account_bank_statement_import_ofx/i18n/lt_LT.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2016 msgid "" @@ -11,12 +11,14 @@ msgstr "" "POT-Creation-Date: 2017-04-11 21:55+0000\n" "PO-Revision-Date: 2017-04-11 21:55+0000\n" "Last-Translator: OCA Transbot , 2016\n" -"Language-Team: Lithuanian (Lithuania) (https://www.transifex.com/oca/teams/23907/lt_LT/)\n" +"Language-Team: Lithuanian (Lithuania) (https://www.transifex.com/oca/" +"teams/23907/lt_LT/)\n" +"Language: lt_LT\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: lt_LT\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n" +"%100<10 || n%100>=20) ? 1 : 2);\n" #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import @@ -29,7 +31,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/nb_NO.po b/account_bank_statement_import_ofx/i18n/nb_NO.po index e81a792c..06acf96d 100644 --- a/account_bank_statement_import_ofx/i18n/nb_NO.po +++ b/account_bank_statement_import_ofx/i18n/nb_NO.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-03-19 03:39+0000\n" "PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: OCA Transbot , 2017\n" -"Language-Team: Norwegian Bokmål (Norway) (https://www.transifex.com/oca/teams/23907/nb_NO/)\n" +"Language-Team: Norwegian Bokmål (Norway) (https://www.transifex.com/oca/" +"teams/23907/nb_NO/)\n" +"Language: nb_NO\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: nb_NO\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: account_bank_statement_import_ofx @@ -29,7 +30,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/nl.po b/account_bank_statement_import_ofx/i18n/nl.po index bef900f6..96f25a05 100644 --- a/account_bank_statement_import_ofx/i18n/nl.po +++ b/account_bank_statement_import_ofx/i18n/nl.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2016 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-04-11 21:55+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" +"Language: nl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: nl\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: account_bank_statement_import_ofx @@ -29,13 +29,14 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" msgstr "" -"Het volgende probleem is opgetreden tijdens de import. Het bestand is waarschijnlijk niet juist.\n" +"Het volgende probleem is opgetreden tijdens de import. Het bestand is " +"waarschijnlijk niet juist.\n" "\n" "%s" diff --git a/account_bank_statement_import_ofx/i18n/pt_BR.po b/account_bank_statement_import_ofx/i18n/pt_BR.po index 325d5d24..028e2eb6 100644 --- a/account_bank_statement_import_ofx/i18n/pt_BR.po +++ b/account_bank_statement_import_ofx/i18n/pt_BR.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-11-21 01:42+0000\n" "PO-Revision-Date: 2017-11-21 01:42+0000\n" "Last-Translator: OCA Transbot , 2017\n" -"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: account_bank_statement_import_ofx @@ -29,13 +30,14 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" "\n" " %s" msgstr "" -"O seguinte problema ocorreu durante a importação. O arquivo não deve ser válido.\n" +"O seguinte problema ocorreu durante a importação. O arquivo não deve ser " +"válido.\n" "\n" "%s" diff --git a/account_bank_statement_import_ofx/i18n/pt_PT.po b/account_bank_statement_import_ofx/i18n/pt_PT.po index 4d00797f..80381740 100644 --- a/account_bank_statement_import_ofx/i18n/pt_PT.po +++ b/account_bank_statement_import_ofx/i18n/pt_PT.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-03-19 03:39+0000\n" "PO-Revision-Date: 2017-03-19 03:39+0000\n" "Last-Translator: OCA Transbot , 2017\n" -"Language-Team: Portuguese (Portugal) (https://www.transifex.com/oca/teams/23907/pt_PT/)\n" +"Language-Team: Portuguese (Portugal) (https://www.transifex.com/oca/" +"teams/23907/pt_PT/)\n" +"Language: pt_PT\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: pt_PT\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: account_bank_statement_import_ofx @@ -29,7 +30,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:75 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/sl.po b/account_bank_statement_import_ofx/i18n/sl.po index f906c954..4c90d8df 100644 --- a/account_bank_statement_import_ofx/i18n/sl.po +++ b/account_bank_statement_import_ofx/i18n/sl.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_bank_statement_import_ofx -# +# # Translators: # OCA Transbot , 2016 msgid "" @@ -12,11 +12,12 @@ msgstr "" "PO-Revision-Date: 2017-04-11 21:55+0000\n" "Last-Translator: OCA Transbot , 2016\n" "Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: sl\n" -"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import @@ -29,7 +30,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:65 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" From 2f9d17ea7effa50a8bb54efa7c717908270b87c2 Mon Sep 17 00:00:00 2001 From: remi-filament <30716308+remi-filament@users.noreply.github.com> Date: Tue, 4 Jun 2019 15:39:26 +0200 Subject: [PATCH 40/50] [MIG] account_bank_statement_import_ofx : Migration to V12 --- account_bank_statement_import_ofx/README.rst | 1 + account_bank_statement_import_ofx/__init__.py | 1 + account_bank_statement_import_ofx/__manifest__.py | 3 ++- .../models/__init__.py | 1 + .../models/account_journal.py | 14 ++++++++++++++ .../tests/test_import_bank_statement.py | 5 +++-- 6 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 account_bank_statement_import_ofx/models/__init__.py create mode 100644 account_bank_statement_import_ofx/models/account_journal.py diff --git a/account_bank_statement_import_ofx/README.rst b/account_bank_statement_import_ofx/README.rst index 84354309..48ce1f79 100644 --- a/account_bank_statement_import_ofx/README.rst +++ b/account_bank_statement_import_ofx/README.rst @@ -49,6 +49,7 @@ Contributors * Ronald Portier * Sylvain LE GAL * Nicolas JEUDY +* Le Filament Maintainer ---------- diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py index 40272379..9b429614 100644 --- a/account_bank_statement_import_ofx/__init__.py +++ b/account_bank_statement_import_ofx/__init__.py @@ -1 +1,2 @@ +from . import models from . import wizard diff --git a/account_bank_statement_import_ofx/__manifest__.py b/account_bank_statement_import_ofx/__manifest__.py index d4305e7a..d1131d4e 100644 --- a/account_bank_statement_import_ofx/__manifest__.py +++ b/account_bank_statement_import_ofx/__manifest__.py @@ -1,13 +1,14 @@ { 'name': 'Import OFX Bank Statement', 'category': 'Banking addons', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'license': 'AGPL-3', 'author': 'Odoo SA,' 'Akretion,' 'La Louve,' 'GRAP,' 'Nicolas JEUDY,' + 'Le Filament,' 'Odoo Community Association (OCA)', 'website': 'https://odoo-community.org/', 'depends': [ diff --git a/account_bank_statement_import_ofx/models/__init__.py b/account_bank_statement_import_ofx/models/__init__.py new file mode 100644 index 00000000..e18569e6 --- /dev/null +++ b/account_bank_statement_import_ofx/models/__init__.py @@ -0,0 +1 @@ +from . import account_journal \ No newline at end of file diff --git a/account_bank_statement_import_ofx/models/account_journal.py b/account_bank_statement_import_ofx/models/account_journal.py new file mode 100644 index 00000000..83c5fb59 --- /dev/null +++ b/account_bank_statement_import_ofx/models/account_journal.py @@ -0,0 +1,14 @@ +from odoo import models + + +class AccountJournal(models.Model): + _inherit = "account.journal" + + def _get_bank_statements_available_import_formats(self): + """ Adds ofx to supported import formats. + """ + rslt = super( + AccountJournal, + self)._get_bank_statements_available_import_formats() + rslt.append('ofx') + return rslt diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 095dd709..5bbf923b 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -1,6 +1,7 @@ from odoo.tests.common import TransactionCase from odoo.modules.module import get_module_resource import base64 +import datetime class TestOfxFile(TransactionCase): @@ -68,8 +69,8 @@ class TestOfxFile(TransactionCase): line = self.absl_model.search([ ('name', '=', 'Agrolait'), ('statement_id', '=', bank_st_record.id)])[0] - self.assertEquals(line.ref, '219378') - self.assertEquals(line.date, '2013-08-24') + self.assertEqual(line.ref, '219378') + self.assertEqual(line.date, datetime.date(2013, 8, 24)) def test_check_journal_bank_account(self): ofx_file_path = get_module_resource( From e4886fb979dbb6a540ce68f84377b2e0c142d8c7 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Tue, 2 Jul 2019 11:13:46 +0000 Subject: [PATCH 41/50] [UPD] Update account_bank_statement_import_ofx.pot --- .../i18n/account_bank_statement_import_ofx.pot | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot b/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot index 7c267d20..d0ca981c 100644 --- a/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot +++ b/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -19,7 +19,12 @@ msgid "Import Bank Statement" msgstr "" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" From 29a366d86c99079717faebae20888531c9fed8f3 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 20 Jul 2019 12:02:02 +0000 Subject: [PATCH 42/50] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: bank-statement-import-12.0/bank-statement-import-12.0-account_bank_statement_import_ofx Translate-URL: https://translation.odoo-community.org/projects/bank-statement-import-12-0/bank-statement-import-12-0-account_bank_statement_import_ofx/ --- account_bank_statement_import_ofx/i18n/de.po | 7 ++++++- account_bank_statement_import_ofx/i18n/es.po | 7 ++++++- account_bank_statement_import_ofx/i18n/fi.po | 7 ++++++- account_bank_statement_import_ofx/i18n/fr.po | 7 ++++++- account_bank_statement_import_ofx/i18n/fr_CH.po | 7 ++++++- account_bank_statement_import_ofx/i18n/gl.po | 7 ++++++- account_bank_statement_import_ofx/i18n/lt_LT.po | 7 ++++++- account_bank_statement_import_ofx/i18n/nb_NO.po | 7 ++++++- account_bank_statement_import_ofx/i18n/nl.po | 7 ++++++- account_bank_statement_import_ofx/i18n/pt_BR.po | 7 ++++++- account_bank_statement_import_ofx/i18n/pt_PT.po | 7 ++++++- account_bank_statement_import_ofx/i18n/sl.po | 7 ++++++- 12 files changed, 72 insertions(+), 12 deletions(-) diff --git a/account_bank_statement_import_ofx/i18n/de.po b/account_bank_statement_import_ofx/i18n/de.po index 3f881f90..bb7062fc 100644 --- a/account_bank_statement_import_ofx/i18n/de.po +++ b/account_bank_statement_import_ofx/i18n/de.po @@ -24,7 +24,12 @@ msgid "Import Bank Statement" msgstr "Kontoauszug importieren" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "Open Financial Exchange (.OFX Money)" diff --git a/account_bank_statement_import_ofx/i18n/es.po b/account_bank_statement_import_ofx/i18n/es.po index 0e5c3303..b6312c6a 100644 --- a/account_bank_statement_import_ofx/i18n/es.po +++ b/account_bank_statement_import_ofx/i18n/es.po @@ -24,7 +24,12 @@ msgid "Import Bank Statement" msgstr "Importar extracto bancario" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/fi.po b/account_bank_statement_import_ofx/i18n/fi.po index 6617a1d9..8eddb7fa 100644 --- a/account_bank_statement_import_ofx/i18n/fi.po +++ b/account_bank_statement_import_ofx/i18n/fi.po @@ -24,7 +24,12 @@ msgid "Import Bank Statement" msgstr "Tuo pankkiaineisto" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/fr.po b/account_bank_statement_import_ofx/i18n/fr.po index 3e504e99..610718ea 100644 --- a/account_bank_statement_import_ofx/i18n/fr.po +++ b/account_bank_statement_import_ofx/i18n/fr.po @@ -24,7 +24,12 @@ msgid "Import Bank Statement" msgstr "Importer Relevé Bancaire" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "Open Financial Exchange (.OFX Money)" diff --git a/account_bank_statement_import_ofx/i18n/fr_CH.po b/account_bank_statement_import_ofx/i18n/fr_CH.po index f13f1429..73b97879 100644 --- a/account_bank_statement_import_ofx/i18n/fr_CH.po +++ b/account_bank_statement_import_ofx/i18n/fr_CH.po @@ -25,7 +25,12 @@ msgid "Import Bank Statement" msgstr "Importer Relevé" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/gl.po b/account_bank_statement_import_ofx/i18n/gl.po index 9147efad..25af035e 100644 --- a/account_bank_statement_import_ofx/i18n/gl.po +++ b/account_bank_statement_import_ofx/i18n/gl.po @@ -24,7 +24,12 @@ msgid "Import Bank Statement" msgstr "Importar extracto bancario" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/lt_LT.po b/account_bank_statement_import_ofx/i18n/lt_LT.po index 45d0b47d..289bbd0b 100644 --- a/account_bank_statement_import_ofx/i18n/lt_LT.po +++ b/account_bank_statement_import_ofx/i18n/lt_LT.po @@ -26,7 +26,12 @@ msgid "Import Bank Statement" msgstr "Importuoti banko išrašą" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/nb_NO.po b/account_bank_statement_import_ofx/i18n/nb_NO.po index 06acf96d..7aec8f28 100644 --- a/account_bank_statement_import_ofx/i18n/nb_NO.po +++ b/account_bank_statement_import_ofx/i18n/nb_NO.po @@ -25,7 +25,12 @@ msgid "Import Bank Statement" msgstr "Importer bankutsagn" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/nl.po b/account_bank_statement_import_ofx/i18n/nl.po index 96f25a05..5de203ca 100644 --- a/account_bank_statement_import_ofx/i18n/nl.po +++ b/account_bank_statement_import_ofx/i18n/nl.po @@ -24,7 +24,12 @@ msgid "Import Bank Statement" msgstr "Importeer bankafschrift" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/pt_BR.po b/account_bank_statement_import_ofx/i18n/pt_BR.po index 028e2eb6..9ec8f9c5 100644 --- a/account_bank_statement_import_ofx/i18n/pt_BR.po +++ b/account_bank_statement_import_ofx/i18n/pt_BR.po @@ -25,7 +25,12 @@ msgid "Import Bank Statement" msgstr "Importar Extrato Bancário" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/pt_PT.po b/account_bank_statement_import_ofx/i18n/pt_PT.po index 80381740..5251ffc6 100644 --- a/account_bank_statement_import_ofx/i18n/pt_PT.po +++ b/account_bank_statement_import_ofx/i18n/pt_PT.po @@ -25,7 +25,12 @@ msgid "Import Bank Statement" msgstr "Importar Extrato Bancário" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" diff --git a/account_bank_statement_import_ofx/i18n/sl.po b/account_bank_statement_import_ofx/i18n/sl.po index 4c90d8df..4bced1f0 100644 --- a/account_bank_statement_import_ofx/i18n/sl.po +++ b/account_bank_statement_import_ofx/i18n/sl.po @@ -25,7 +25,12 @@ msgid "Import Bank Statement" msgstr "Uvoz bančnega izpiska" #. module: account_bank_statement_import_ofx -#: model:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form +#: model:ir.model,name:account_bank_statement_import_ofx.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_bank_statement_import_ofx +#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" msgstr "" From c8e7242398f7021eb37ae820947a31b8cd804187 Mon Sep 17 00:00:00 2001 From: Rodrigo Macedo Date: Mon, 26 Aug 2019 12:12:12 +0000 Subject: [PATCH 43/50] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (3 of 3 strings) Translation: bank-statement-import-12.0/bank-statement-import-12.0-account_bank_statement_import_ofx Translate-URL: https://translation.odoo-community.org/projects/bank-statement-import-12-0/bank-statement-import-12-0-account_bank_statement_import_ofx/pt_BR/ --- account_bank_statement_import_ofx/i18n/pt_BR.po | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/account_bank_statement_import_ofx/i18n/pt_BR.po b/account_bank_statement_import_ofx/i18n/pt_BR.po index 9ec8f9c5..af10ccd8 100644 --- a/account_bank_statement_import_ofx/i18n/pt_BR.po +++ b/account_bank_statement_import_ofx/i18n/pt_BR.po @@ -9,15 +9,16 @@ msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2017-11-21 01:42+0000\n" -"PO-Revision-Date: 2017-11-21 01:42+0000\n" -"Last-Translator: OCA Transbot , 2017\n" -"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" -"teams/23907/pt_BR/)\n" +"PO-Revision-Date: 2019-08-26 15:01+0000\n" +"Last-Translator: Rodrigo Macedo \n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/" +"23907/pt_BR/)\n" "Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.8\n" #. module: account_bank_statement_import_ofx #: model:ir.model,name:account_bank_statement_import_ofx.model_account_bank_statement_import @@ -32,7 +33,7 @@ msgstr "" #. module: account_bank_statement_import_ofx #: model_terms:ir.ui.view,arch_db:account_bank_statement_import_ofx.view_account_bank_statement_import_form msgid "Open Financial Exchange (.OFX Money)" -msgstr "" +msgstr "Troca Financeira Aberta (.OFX Money)" #. module: account_bank_statement_import_ofx #: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 From faf50112726fe8c479ef186a73283c984bb5dbaa Mon Sep 17 00:00:00 2001 From: David Beal Date: Tue, 26 Nov 2019 16:40:32 +0100 Subject: [PATCH 44/50] IMP acc_bank_stat_imp_ofx: add checknum in name when required --- .../wizard/account_bank_statement_import.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py index 8944add3..15af6d0f 100644 --- a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -53,10 +53,14 @@ class AccountBankStatementImport(models.TransientModel): # If you read odoo10/addons/account_bank_statement_import/ # account_bank_statement_import.py, it's the only 2 keys # we can provide to match a partner. + name = transaction.payee + if transaction.checknum: + name += " " + transaction.checknum + if transaction.memo: + name += " : " + transaction.memo vals = { 'date': transaction.date, - 'name': transaction.payee + ( - transaction.memo and ': ' + transaction.memo or ''), + 'name': name, 'ref': transaction.id, 'amount': float(transaction.amount), 'unique_import_id': transaction.id, From eee1ecc20f66635ce62e908371f4fcce71855d2d Mon Sep 17 00:00:00 2001 From: oca-travis Date: Wed, 27 Nov 2019 09:43:19 +0000 Subject: [PATCH 45/50] [UPD] Update account_bank_statement_import_ofx.pot --- .../i18n/account_bank_statement_import_ofx.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot b/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot index d0ca981c..8f4b849a 100644 --- a/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot +++ b/account_bank_statement_import_ofx/i18n/account_bank_statement_import_ofx.pot @@ -29,7 +29,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "The following problem occurred during import. The file might not be valid.\n" "\n" From 7eb0b9bccae2e5e8ad7b903fea6c5a38357ccf5b Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 27 Nov 2019 09:49:55 +0000 Subject: [PATCH 46/50] account_bank_statement_import_ofx 12.0.1.1.0 --- account_bank_statement_import_ofx/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_ofx/__manifest__.py b/account_bank_statement_import_ofx/__manifest__.py index d1131d4e..d1fc2aef 100644 --- a/account_bank_statement_import_ofx/__manifest__.py +++ b/account_bank_statement_import_ofx/__manifest__.py @@ -1,7 +1,7 @@ { 'name': 'Import OFX Bank Statement', 'category': 'Banking addons', - 'version': '12.0.1.0.0', + 'version': '12.0.1.1.0', 'license': 'AGPL-3', 'author': 'Odoo SA,' 'Akretion,' From ab7de2959cbe7149097a69e7e21a25fccf9fe3a4 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Wed, 27 Nov 2019 09:50:06 +0000 Subject: [PATCH 47/50] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: bank-statement-import-12.0/bank-statement-import-12.0-account_bank_statement_import_ofx Translate-URL: https://translation.odoo-community.org/projects/bank-statement-import-12-0/bank-statement-import-12-0-account_bank_statement_import_ofx/ --- account_bank_statement_import_ofx/i18n/de.po | 2 +- account_bank_statement_import_ofx/i18n/es.po | 2 +- account_bank_statement_import_ofx/i18n/fi.po | 2 +- account_bank_statement_import_ofx/i18n/fr.po | 2 +- account_bank_statement_import_ofx/i18n/fr_CH.po | 2 +- account_bank_statement_import_ofx/i18n/gl.po | 2 +- account_bank_statement_import_ofx/i18n/lt_LT.po | 2 +- account_bank_statement_import_ofx/i18n/nb_NO.po | 2 +- account_bank_statement_import_ofx/i18n/nl.po | 2 +- account_bank_statement_import_ofx/i18n/pt_BR.po | 6 +++--- account_bank_statement_import_ofx/i18n/pt_PT.po | 2 +- account_bank_statement_import_ofx/i18n/sl.po | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/account_bank_statement_import_ofx/i18n/de.po b/account_bank_statement_import_ofx/i18n/de.po index bb7062fc..a5bf93d9 100644 --- a/account_bank_statement_import_ofx/i18n/de.po +++ b/account_bank_statement_import_ofx/i18n/de.po @@ -34,7 +34,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "Open Financial Exchange (.OFX Money)" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/es.po b/account_bank_statement_import_ofx/i18n/es.po index b6312c6a..a2084c95 100644 --- a/account_bank_statement_import_ofx/i18n/es.po +++ b/account_bank_statement_import_ofx/i18n/es.po @@ -34,7 +34,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/fi.po b/account_bank_statement_import_ofx/i18n/fi.po index 8eddb7fa..d7d0bcdf 100644 --- a/account_bank_statement_import_ofx/i18n/fi.po +++ b/account_bank_statement_import_ofx/i18n/fi.po @@ -34,7 +34,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/fr.po b/account_bank_statement_import_ofx/i18n/fr.po index 610718ea..1d14c157 100644 --- a/account_bank_statement_import_ofx/i18n/fr.po +++ b/account_bank_statement_import_ofx/i18n/fr.po @@ -34,7 +34,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "Open Financial Exchange (.OFX Money)" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/fr_CH.po b/account_bank_statement_import_ofx/i18n/fr_CH.po index 73b97879..f8d71090 100644 --- a/account_bank_statement_import_ofx/i18n/fr_CH.po +++ b/account_bank_statement_import_ofx/i18n/fr_CH.po @@ -35,7 +35,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/gl.po b/account_bank_statement_import_ofx/i18n/gl.po index 25af035e..0d778259 100644 --- a/account_bank_statement_import_ofx/i18n/gl.po +++ b/account_bank_statement_import_ofx/i18n/gl.po @@ -34,7 +34,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/lt_LT.po b/account_bank_statement_import_ofx/i18n/lt_LT.po index 289bbd0b..dc6a91fb 100644 --- a/account_bank_statement_import_ofx/i18n/lt_LT.po +++ b/account_bank_statement_import_ofx/i18n/lt_LT.po @@ -36,7 +36,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/nb_NO.po b/account_bank_statement_import_ofx/i18n/nb_NO.po index 7aec8f28..78c5628f 100644 --- a/account_bank_statement_import_ofx/i18n/nb_NO.po +++ b/account_bank_statement_import_ofx/i18n/nb_NO.po @@ -35,7 +35,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/nl.po b/account_bank_statement_import_ofx/i18n/nl.po index 5de203ca..bbcb3e18 100644 --- a/account_bank_statement_import_ofx/i18n/nl.po +++ b/account_bank_statement_import_ofx/i18n/nl.po @@ -34,7 +34,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/pt_BR.po b/account_bank_statement_import_ofx/i18n/pt_BR.po index af10ccd8..68c536cc 100644 --- a/account_bank_statement_import_ofx/i18n/pt_BR.po +++ b/account_bank_statement_import_ofx/i18n/pt_BR.po @@ -11,8 +11,8 @@ msgstr "" "POT-Creation-Date: 2017-11-21 01:42+0000\n" "PO-Revision-Date: 2019-08-26 15:01+0000\n" "Last-Translator: Rodrigo Macedo \n" -"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/" -"23907/pt_BR/)\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" "Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -36,7 +36,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "Troca Financeira Aberta (.OFX Money)" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/pt_PT.po b/account_bank_statement_import_ofx/i18n/pt_PT.po index 5251ffc6..4f1b36b3 100644 --- a/account_bank_statement_import_ofx/i18n/pt_PT.po +++ b/account_bank_statement_import_ofx/i18n/pt_PT.po @@ -35,7 +35,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" diff --git a/account_bank_statement_import_ofx/i18n/sl.po b/account_bank_statement_import_ofx/i18n/sl.po index 4bced1f0..41b639a3 100644 --- a/account_bank_statement_import_ofx/i18n/sl.po +++ b/account_bank_statement_import_ofx/i18n/sl.po @@ -35,7 +35,7 @@ msgid "Open Financial Exchange (.OFX Money)" msgstr "" #. module: account_bank_statement_import_ofx -#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:81 +#: code:addons/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py:85 #, python-format msgid "" "The following problem occurred during import. The file might not be valid.\n" From e6cf63d6f494872e0bb8d9c5594cee557513af41 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 16 May 2020 01:27:35 +0200 Subject: [PATCH 48/50] [MIG] ofx from v12 to v13 --- .../__manifest__.py | 4 ++-- .../models/account_journal.py | 4 +--- .../readme/CONTRIBUTORS.rst | 7 +++++++ .../readme/DESCRIPTION.rst | 4 ++++ .../readme/INSTALL.rst | 1 + .../tests/test_import_bank_statement.py | 19 ++++++++++++++++--- .../wizard/account_bank_statement_import.py | 7 ++----- 7 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 account_bank_statement_import_ofx/readme/CONTRIBUTORS.rst create mode 100644 account_bank_statement_import_ofx/readme/DESCRIPTION.rst create mode 100644 account_bank_statement_import_ofx/readme/INSTALL.rst diff --git a/account_bank_statement_import_ofx/__manifest__.py b/account_bank_statement_import_ofx/__manifest__.py index d1fc2aef..96b0dfd8 100644 --- a/account_bank_statement_import_ofx/__manifest__.py +++ b/account_bank_statement_import_ofx/__manifest__.py @@ -1,7 +1,7 @@ { 'name': 'Import OFX Bank Statement', 'category': 'Banking addons', - 'version': '12.0.1.1.0', + 'version': '13.0.1.0.0', 'license': 'AGPL-3', 'author': 'Odoo SA,' 'Akretion,' @@ -10,7 +10,7 @@ 'Nicolas JEUDY,' 'Le Filament,' 'Odoo Community Association (OCA)', - 'website': 'https://odoo-community.org/', + 'website': 'https://github.com/OCA/bank-statement-import', 'depends': [ 'account_bank_statement_import', ], diff --git a/account_bank_statement_import_ofx/models/account_journal.py b/account_bank_statement_import_ofx/models/account_journal.py index 83c5fb59..be290b94 100644 --- a/account_bank_statement_import_ofx/models/account_journal.py +++ b/account_bank_statement_import_ofx/models/account_journal.py @@ -7,8 +7,6 @@ class AccountJournal(models.Model): def _get_bank_statements_available_import_formats(self): """ Adds ofx to supported import formats. """ - rslt = super( - AccountJournal, - self)._get_bank_statements_available_import_formats() + rslt = super()._get_bank_statements_available_import_formats() rslt.append('ofx') return rslt diff --git a/account_bank_statement_import_ofx/readme/CONTRIBUTORS.rst b/account_bank_statement_import_ofx/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..06df3953 --- /dev/null +++ b/account_bank_statement_import_ofx/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* Odoo SA +* Alexis de Lattre +* Laurent Mignon +* Ronald Portier +* Sylvain LE GAL +* Nicolas JEUDY +* Le Filament diff --git a/account_bank_statement_import_ofx/readme/DESCRIPTION.rst b/account_bank_statement_import_ofx/readme/DESCRIPTION.rst new file mode 100644 index 00000000..bbc412a0 --- /dev/null +++ b/account_bank_statement_import_ofx/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module adds support for the import of bank statements in `OFX format `_. + +Bank Statements may be generated containing a subset of the OFX information (only those transaction lines that are required for the +creation of the Financial Accounting records). diff --git a/account_bank_statement_import_ofx/readme/INSTALL.rst b/account_bank_statement_import_ofx/readme/INSTALL.rst new file mode 100644 index 00000000..39c87234 --- /dev/null +++ b/account_bank_statement_import_ofx/readme/INSTALL.rst @@ -0,0 +1 @@ +This module requires the `ofxparse `_ python lib. diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 5bbf923b..fd27cd65 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -15,6 +15,7 @@ class TestOfxFile(TransactionCase): self.abs_model = self.env['account.bank.statement'] self.j_model = self.env['account.journal'] self.absl_model = self.env['account.bank.statement.line'] + self.ia_model = self.env['ir.attachment'] cur = self.env.ref('base.USD') self.env.ref('base.main_company').currency_id = cur.id bank = self.env['res.partner.bank'].create({ @@ -49,8 +50,12 @@ class TestOfxFile(TransactionCase): 'account_bank_statement_import_ofx', 'tests/test_ofx_file/', 'test_ofx_wrong.ofx') ofx_file_wrong = base64.b64encode(open(ofx_file_path, 'rb').read()) + attach = self.ia_model.create({ + 'name': 'test_ofx_wrong.ofx', + 'datas': ofx_file_wrong, + }) bank_statement = self.absi_model.create( - dict(data_file=ofx_file_wrong)) + dict(attachment_ids=[(6, 0, [attach.id])])) self.assertFalse(bank_statement._check_ofx(data_file=ofx_file_wrong)) def test_ofx_file_import(self): @@ -58,8 +63,12 @@ class TestOfxFile(TransactionCase): 'account_bank_statement_import_ofx', 'tests/test_ofx_file/', 'test_ofx.ofx') ofx_file = base64.b64encode(open(ofx_file_path, 'rb').read()) + attach = self.ia_model.create({ + 'name': 'test_ofx.ofx', + 'datas': ofx_file, + }) bank_statement = self.absi_model.create( - dict(data_file=ofx_file)) + dict(attachment_ids=[(6, 0, [attach.id])])) bank_statement.import_file() bank_st_record = self.abs_model.search( [('name', 'like', '123456')])[0] @@ -77,8 +86,12 @@ class TestOfxFile(TransactionCase): 'account_bank_statement_import_ofx', 'tests/test_ofx_file/', 'test_ofx_iban.ofx') ofx_file = base64.b64encode(open(ofx_file_path, 'rb').read()) + attach = self.ia_model.create({ + 'name': 'test_ofx.ofx', + 'datas': ofx_file, + }) bank_st = self.absi_model.create( - dict(data_file=ofx_file)) + dict(attachment_ids=[(6, 0, [attach.id])])) journal_iban_ofx = self.j_model.search([ ('name', '=', 'FR7630001007941234567890185')]) res = bank_st._check_journal_bank_account(journal_iban_ofx, diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py index 15af6d0f..775f76be 100644 --- a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -19,9 +19,7 @@ class AccountBankStatementImport(models.TransientModel): _inherit = 'account.bank.statement.import' def _check_journal_bank_account(self, journal, account_number): - res = super( - AccountBankStatementImport, self - )._check_journal_bank_account(journal, account_number) + res = super()._check_journal_bank_account(journal, account_number) if not res: e_acc_num = journal.bank_account_id.sanitized_acc_number e_acc_num = e_acc_num.replace(" ", "") @@ -70,8 +68,7 @@ class AccountBankStatementImport(models.TransientModel): def _parse_file(self, data_file): ofx = self._check_ofx(data_file) if not ofx: - return super(AccountBankStatementImport, self)._parse_file( - data_file) + return super()._parse_file(data_file) transactions = [] total_amt = 0.00 From cff642130d944ed8b10b6b8b802e2589b03c22f3 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 16 May 2020 01:28:57 +0200 Subject: [PATCH 49/50] ofx: black and others... --- .../__manifest__.py | 38 ++--- .../models/__init__.py | 2 +- .../models/account_journal.py | 2 +- .../tests/test_import_bank_statement.py | 142 +++++++++--------- .../view_account_bank_statement_import.xml | 7 +- .../wizard/account_bank_statement_import.py | 54 ++++--- .../addons/account_bank_statement_import_ofx | 1 + .../setup.py | 6 + 8 files changed, 134 insertions(+), 118 deletions(-) create mode 120000 setup/account_bank_statement_import_ofx/odoo/addons/account_bank_statement_import_ofx create mode 100644 setup/account_bank_statement_import_ofx/setup.py diff --git a/account_bank_statement_import_ofx/__manifest__.py b/account_bank_statement_import_ofx/__manifest__.py index 96b0dfd8..3ac95a12 100644 --- a/account_bank_statement_import_ofx/__manifest__.py +++ b/account_bank_statement_import_ofx/__manifest__.py @@ -1,24 +1,18 @@ { - 'name': 'Import OFX Bank Statement', - 'category': 'Banking addons', - 'version': '13.0.1.0.0', - 'license': 'AGPL-3', - 'author': 'Odoo SA,' - 'Akretion,' - 'La Louve,' - 'GRAP,' - 'Nicolas JEUDY,' - 'Le Filament,' - 'Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/bank-statement-import', - 'depends': [ - 'account_bank_statement_import', - ], - 'data': [ - 'views/view_account_bank_statement_import.xml', - ], - 'external_dependencies': { - 'python': ['ofxparse'], - }, - 'installable': True, + "name": "Import OFX Bank Statement", + "category": "Banking addons", + "version": "13.0.1.0.0", + "license": "AGPL-3", + "author": "Odoo SA," + "Akretion," + "La Louve," + "GRAP," + "Nicolas JEUDY," + "Le Filament," + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/bank-statement-import", + "depends": ["account_bank_statement_import",], + "data": ["views/view_account_bank_statement_import.xml",], + "external_dependencies": {"python": ["ofxparse"],}, + "installable": True, } diff --git a/account_bank_statement_import_ofx/models/__init__.py b/account_bank_statement_import_ofx/models/__init__.py index e18569e6..2388e119 100644 --- a/account_bank_statement_import_ofx/models/__init__.py +++ b/account_bank_statement_import_ofx/models/__init__.py @@ -1 +1 @@ -from . import account_journal \ No newline at end of file +from . import account_journal diff --git a/account_bank_statement_import_ofx/models/account_journal.py b/account_bank_statement_import_ofx/models/account_journal.py index be290b94..fb6c480e 100644 --- a/account_bank_statement_import_ofx/models/account_journal.py +++ b/account_bank_statement_import_ofx/models/account_journal.py @@ -8,5 +8,5 @@ class AccountJournal(models.Model): """ Adds ofx to supported import formats. """ rslt = super()._get_bank_statements_available_import_formats() - rslt.append('ofx') + rslt.append("ofx") return rslt diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index fd27cd65..752e0614 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -1,8 +1,9 @@ -from odoo.tests.common import TransactionCase -from odoo.modules.module import get_module_resource import base64 import datetime +from odoo.modules.module import get_module_resource +from odoo.tests.common import TransactionCase + class TestOfxFile(TransactionCase): """Tests for import bank statement ofx file format @@ -11,90 +12,95 @@ class TestOfxFile(TransactionCase): def setUp(self): super(TestOfxFile, self).setUp() - self.absi_model = self.env['account.bank.statement.import'] - self.abs_model = self.env['account.bank.statement'] - self.j_model = self.env['account.journal'] - self.absl_model = self.env['account.bank.statement.line'] - self.ia_model = self.env['ir.attachment'] - cur = self.env.ref('base.USD') - self.env.ref('base.main_company').currency_id = cur.id - bank = self.env['res.partner.bank'].create({ - 'acc_number': '123456', - 'partner_id': self.env.ref('base.main_partner').id, - 'company_id': self.env.ref('base.main_company').id, - 'bank_id': self.env.ref('base.res_bank_1').id, - }) - self.env['account.journal'].create({ - 'name': 'Bank Journal TEST OFX', - 'code': 'BNK12', - 'type': 'bank', - 'bank_account_id': bank.id, - }) + self.absi_model = self.env["account.bank.statement.import"] + self.abs_model = self.env["account.bank.statement"] + self.j_model = self.env["account.journal"] + self.absl_model = self.env["account.bank.statement.line"] + self.ia_model = self.env["ir.attachment"] + cur = self.env.ref("base.USD") + self.env.ref("base.main_company").currency_id = cur.id + bank = self.env["res.partner.bank"].create( + { + "acc_number": "123456", + "partner_id": self.env.ref("base.main_partner").id, + "company_id": self.env.ref("base.main_company").id, + "bank_id": self.env.ref("base.res_bank_1").id, + } + ) + self.env["account.journal"].create( + { + "name": "Bank Journal TEST OFX", + "code": "BNK12", + "type": "bank", + "bank_account_id": bank.id, + } + ) - bank_iban_ofx = self.env['res.partner.bank'].create({ - 'acc_number': 'FR7630001007941234567890185', - 'partner_id': self.env.ref('base.main_partner').id, - 'company_id': self.env.ref('base.main_company').id, - 'bank_id': self.env.ref('base.res_bank_1').id, - }) + bank_iban_ofx = self.env["res.partner.bank"].create( + { + "acc_number": "FR7630001007941234567890185", + "partner_id": self.env.ref("base.main_partner").id, + "company_id": self.env.ref("base.main_company").id, + "bank_id": self.env.ref("base.res_bank_1").id, + } + ) - self.env['account.journal'].create({ - 'name': 'FR7630001007941234567890185', - 'code': 'BNK13', - 'type': 'bank', - 'bank_account_id': bank_iban_ofx.id, - }) + self.env["account.journal"].create( + { + "name": "FR7630001007941234567890185", + "code": "BNK13", + "type": "bank", + "bank_account_id": bank_iban_ofx.id, + } + ) def test_wrong_ofx_file_import(self): ofx_file_path = get_module_resource( - 'account_bank_statement_import_ofx', - 'tests/test_ofx_file/', 'test_ofx_wrong.ofx') - ofx_file_wrong = base64.b64encode(open(ofx_file_path, 'rb').read()) - attach = self.ia_model.create({ - 'name': 'test_ofx_wrong.ofx', - 'datas': ofx_file_wrong, - }) + "account_bank_statement_import_ofx", + "tests/test_ofx_file/", + "test_ofx_wrong.ofx", + ) + ofx_file_wrong = base64.b64encode(open(ofx_file_path, "rb").read()) + attach = self.ia_model.create( + {"name": "test_ofx_wrong.ofx", "datas": ofx_file_wrong,} + ) bank_statement = self.absi_model.create( - dict(attachment_ids=[(6, 0, [attach.id])])) + dict(attachment_ids=[(6, 0, [attach.id])]) + ) self.assertFalse(bank_statement._check_ofx(data_file=ofx_file_wrong)) def test_ofx_file_import(self): ofx_file_path = get_module_resource( - 'account_bank_statement_import_ofx', - 'tests/test_ofx_file/', 'test_ofx.ofx') - ofx_file = base64.b64encode(open(ofx_file_path, 'rb').read()) - attach = self.ia_model.create({ - 'name': 'test_ofx.ofx', - 'datas': ofx_file, - }) + "account_bank_statement_import_ofx", "tests/test_ofx_file/", "test_ofx.ofx" + ) + ofx_file = base64.b64encode(open(ofx_file_path, "rb").read()) + attach = self.ia_model.create({"name": "test_ofx.ofx", "datas": ofx_file,}) bank_statement = self.absi_model.create( - dict(attachment_ids=[(6, 0, [attach.id])])) + dict(attachment_ids=[(6, 0, [attach.id])]) + ) bank_statement.import_file() - bank_st_record = self.abs_model.search( - [('name', 'like', '123456')])[0] + bank_st_record = self.abs_model.search([("name", "like", "123456")])[0] self.assertEqual(bank_st_record.balance_start, 2516.56) self.assertEqual(bank_st_record.balance_end_real, 2156.56) - line = self.absl_model.search([ - ('name', '=', 'Agrolait'), - ('statement_id', '=', bank_st_record.id)])[0] - self.assertEqual(line.ref, '219378') + line = self.absl_model.search( + [("name", "=", "Agrolait"), ("statement_id", "=", bank_st_record.id)] + )[0] + self.assertEqual(line.ref, "219378") self.assertEqual(line.date, datetime.date(2013, 8, 24)) def test_check_journal_bank_account(self): ofx_file_path = get_module_resource( - 'account_bank_statement_import_ofx', - 'tests/test_ofx_file/', 'test_ofx_iban.ofx') - ofx_file = base64.b64encode(open(ofx_file_path, 'rb').read()) - attach = self.ia_model.create({ - 'name': 'test_ofx.ofx', - 'datas': ofx_file, - }) - bank_st = self.absi_model.create( - dict(attachment_ids=[(6, 0, [attach.id])])) - journal_iban_ofx = self.j_model.search([ - ('name', '=', 'FR7630001007941234567890185')]) - res = bank_st._check_journal_bank_account(journal_iban_ofx, - '12345678901') + "account_bank_statement_import_ofx", + "tests/test_ofx_file/", + "test_ofx_iban.ofx", + ) + ofx_file = base64.b64encode(open(ofx_file_path, "rb").read()) + attach = self.ia_model.create({"name": "test_ofx.ofx", "datas": ofx_file,}) + bank_st = self.absi_model.create(dict(attachment_ids=[(6, 0, [attach.id])])) + journal_iban_ofx = self.j_model.search( + [("name", "=", "FR7630001007941234567890185")] + ) + res = bank_st._check_journal_bank_account(journal_iban_ofx, "12345678901") self.assertTrue(res) bank_st.with_context(journal_id=journal_iban_ofx.id).import_file() diff --git a/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml b/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml index 046ed1e4..c8cd372b 100644 --- a/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml +++ b/account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml @@ -1,8 +1,11 @@ - + account.bank.statement.import - +
  • Open Financial Exchange (.OFX Money)
  • diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py index 775f76be..9618f43c 100644 --- a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -1,10 +1,13 @@ -import logging import io +import logging -from odoo import api, models, _ +from odoo import _, api, models from odoo.exceptions import UserError -from odoo.addons.base_iban.models.res_partner_bank import _map_iban_template -from odoo.addons.base_iban.models.res_partner_bank import validate_iban + +from odoo.addons.base_iban.models.res_partner_bank import ( + _map_iban_template, + validate_iban, +) _logger = logging.getLogger(__name__) @@ -16,7 +19,7 @@ except ImportError: class AccountBankStatementImport(models.TransientModel): - _inherit = 'account.bank.statement.import' + _inherit = "account.bank.statement.import" def _check_journal_bank_account(self, journal, account_number): res = super()._check_journal_bank_account(journal, account_number) @@ -25,11 +28,11 @@ class AccountBankStatementImport(models.TransientModel): e_acc_num = e_acc_num.replace(" ", "") validate_iban(e_acc_num) country_code = e_acc_num[:2].lower() - iban_template = _map_iban_template[country_code].replace( - " ", "") + iban_template = _map_iban_template[country_code].replace(" ", "") e_acc_num = "".join( - [c for c, t in zip(e_acc_num, iban_template) if t == "C"]) - res = (e_acc_num == account_number) + [c for c, t in zip(e_acc_num, iban_template) if t == "C"] + ) + res = e_acc_num == account_number return res @api.model @@ -57,11 +60,11 @@ class AccountBankStatementImport(models.TransientModel): if transaction.memo: name += " : " + transaction.memo vals = { - 'date': transaction.date, - 'name': name, - 'ref': transaction.id, - 'amount': float(transaction.amount), - 'unique_import_id': transaction.id, + "date": transaction.date, + "name": name, + "ref": transaction.id, + "amount": float(transaction.amount), + "unique_import_id": transaction.id, } return vals @@ -77,18 +80,21 @@ class AccountBankStatementImport(models.TransientModel): vals = self._prepare_ofx_transaction_line(transaction) if vals: transactions.append(vals) - total_amt += vals['amount'] + total_amt += vals["amount"] except Exception as e: - raise UserError(_( - "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 + ) balance = float(ofx.account.statement.balance) vals_bank_statement = { - 'name': ofx.account.number, - 'transactions': transactions, - 'balance_start': balance - total_amt, - 'balance_end_real': balance, + "name": ofx.account.number, + "transactions": transactions, + "balance_start": balance - total_amt, + "balance_end_real": balance, } - return ofx.account.statement.currency, ofx.account.number, [ - vals_bank_statement] + return ofx.account.statement.currency, ofx.account.number, [vals_bank_statement] diff --git a/setup/account_bank_statement_import_ofx/odoo/addons/account_bank_statement_import_ofx b/setup/account_bank_statement_import_ofx/odoo/addons/account_bank_statement_import_ofx new file mode 120000 index 00000000..28d70fc2 --- /dev/null +++ b/setup/account_bank_statement_import_ofx/odoo/addons/account_bank_statement_import_ofx @@ -0,0 +1 @@ +../../../../account_bank_statement_import_ofx \ No newline at end of file diff --git a/setup/account_bank_statement_import_ofx/setup.py b/setup/account_bank_statement_import_ofx/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_bank_statement_import_ofx/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From ef981c8d65bd78ffb82e8a50ddcd07c020a50a1d Mon Sep 17 00:00:00 2001 From: RPSJR Date: Sun, 8 Aug 2021 11:45:40 -0300 Subject: [PATCH 50/50] [pre-commit] pre-commit fix issues, only ofx module --- account_bank_statement_import_ofx/__init__.py | 3 +-- account_bank_statement_import_ofx/__manifest__.py | 6 +++--- .../static/description/icon.png | Bin .../tests/test_import_bank_statement.py | 6 +++--- .../wizard/account_bank_statement_import.py | 3 ++- 5 files changed, 9 insertions(+), 9 deletions(-) mode change 100644 => 100755 account_bank_statement_import_ofx/static/description/icon.png diff --git a/account_bank_statement_import_ofx/__init__.py b/account_bank_statement_import_ofx/__init__.py index 9b429614..b046ff82 100644 --- a/account_bank_statement_import_ofx/__init__.py +++ b/account_bank_statement_import_ofx/__init__.py @@ -1,2 +1 @@ -from . import models -from . import wizard +from . import models, wizard diff --git a/account_bank_statement_import_ofx/__manifest__.py b/account_bank_statement_import_ofx/__manifest__.py index 3ac95a12..e92873f4 100644 --- a/account_bank_statement_import_ofx/__manifest__.py +++ b/account_bank_statement_import_ofx/__manifest__.py @@ -11,8 +11,8 @@ "Le Filament," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/bank-statement-import", - "depends": ["account_bank_statement_import",], - "data": ["views/view_account_bank_statement_import.xml",], - "external_dependencies": {"python": ["ofxparse"],}, + "depends": ["account_bank_statement_import"], + "data": ["views/view_account_bank_statement_import.xml"], + "external_dependencies": {"python": ["ofxparse"]}, "installable": True, } diff --git a/account_bank_statement_import_ofx/static/description/icon.png b/account_bank_statement_import_ofx/static/description/icon.png old mode 100644 new mode 100755 diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index 752e0614..aa664642 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -62,7 +62,7 @@ class TestOfxFile(TransactionCase): ) ofx_file_wrong = base64.b64encode(open(ofx_file_path, "rb").read()) attach = self.ia_model.create( - {"name": "test_ofx_wrong.ofx", "datas": ofx_file_wrong,} + {"name": "test_ofx_wrong.ofx", "datas": ofx_file_wrong} ) bank_statement = self.absi_model.create( dict(attachment_ids=[(6, 0, [attach.id])]) @@ -74,7 +74,7 @@ class TestOfxFile(TransactionCase): "account_bank_statement_import_ofx", "tests/test_ofx_file/", "test_ofx.ofx" ) ofx_file = base64.b64encode(open(ofx_file_path, "rb").read()) - attach = self.ia_model.create({"name": "test_ofx.ofx", "datas": ofx_file,}) + attach = self.ia_model.create({"name": "test_ofx.ofx", "datas": ofx_file}) bank_statement = self.absi_model.create( dict(attachment_ids=[(6, 0, [attach.id])]) ) @@ -96,7 +96,7 @@ class TestOfxFile(TransactionCase): "test_ofx_iban.ofx", ) ofx_file = base64.b64encode(open(ofx_file_path, "rb").read()) - attach = self.ia_model.create({"name": "test_ofx.ofx", "datas": ofx_file,}) + attach = self.ia_model.create({"name": "test_ofx.ofx", "datas": ofx_file}) bank_st = self.absi_model.create(dict(attachment_ids=[(6, 0, [attach.id])])) journal_iban_ofx = self.j_model.search( [("name", "=", "FR7630001007941234567890185")] diff --git a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py index 9618f43c..964c3f41 100644 --- a/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_ofx/wizard/account_bank_statement_import.py @@ -87,7 +87,8 @@ class AccountBankStatementImport(models.TransientModel): "The following problem occurred during import. " "The file might not be valid.\n\n %s" ) - % e.message + # % e.message # flake8 B306 `BaseException.message` + % e.args[0] ) balance = float(ofx.account.statement.balance)