From 74c4ebdf4f2401fbc7588af0a460947344f25714 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 10:18:55 +0100 Subject: [PATCH 01/40] [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 0000000..fe838c2 --- /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 0000000..8cd569b --- /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 0000000..13966c0 --- /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 0000000..37df4d0 --- /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 0000000..8a5a8e9 --- /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 0000000..967d647 --- /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 64e0c62114569f08758c86781c724d6fcce7b7b3 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 12:00:52 +0100 Subject: [PATCH 02/40] [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 37df4d0..a1bf391 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 0bdfe92bc9a4456c81464ea85918db11ebe56fc3 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 12:37:19 +0100 Subject: [PATCH 03/40] [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 13966c0..6f690a7 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 967d647..f804f90 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 5dc6d51ad019779a11068c5d803c507ce7aa4566 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 12:59:11 +0100 Subject: [PATCH 04/40] [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 8cd569b..8142901 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 a1bf391..37df4d0 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 624d601e4f29cbd1b8f8f9df4ccd956b8cca2204 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Mon, 15 Dec 2014 14:07:54 +0100 Subject: [PATCH 05/40] [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 8142901..25056dd 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 46f42c8b4d6c7b9cb0297ff276778594a82c9b79 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Sun, 21 Dec 2014 13:41:43 +0100 Subject: [PATCH 06/40] [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 fe838c2..146530c 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 8a5a8e9..fa3fb30 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 5bcd425f49a1f2ca2a7db24450117038b97b4855 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Sun, 21 Dec 2014 14:20:09 +0100 Subject: [PATCH 07/40] [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 146530c..44bd24d 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 0aba7282e174260c650d2b5a48627242d02c4c98 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 23 Jan 2015 22:50:24 +0100 Subject: [PATCH 08/40] 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 25056dd..8d2d4ee 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 6f690a7..cf0eb8a 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/40] 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 2391fd1..4bdb2a1 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 3b700d7f05ad1097c08aaa2a71e5a75e5c69b818 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 2 Feb 2015 12:56:30 +0100 Subject: [PATCH 10/40] 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 4bdb2a1..ebdbe11 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 3e2372dabf1bdb250b46c44d6dd4c2d23c8a6167 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Sat, 7 Feb 2015 02:09:35 +0100 Subject: [PATCH 11/40] [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 8d2d4ee..8a10b59 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 0000000..8387f27 --- /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 dcc7297e0df458482dd0f4ab03a8ca574fa0834d Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Fri, 20 Mar 2015 11:48:55 +0100 Subject: [PATCH 12/40] [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 44bd24d..9955438 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 8a10b59..c71cd77 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 cf0eb8a..0442f03 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 ebdbe11..2391fd1 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 dca15a8f09789452d432f5c000e868dbcbd6d3e1 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Thu, 21 May 2015 14:03:51 +0200 Subject: [PATCH 13/40] [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 9955438..fb5e0c3 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 0442f03..93c8931 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 2391fd1..578fe57 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 3fe7654cca2e15c451b60a97b9ed4441b18a93fa Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Sun, 22 Mar 2015 22:11:24 +0100 Subject: [PATCH 14/40] [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 578fe57..ad54f3d 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 92487a8d0f5dabe713de24b2d92426b775503531 Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Fri, 3 Apr 2015 09:04:54 +0200 Subject: [PATCH 15/40] [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 c71cd77..8832984 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 8387f27..0000000 --- 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 47dadc733280be1549d9f8f997802eef26e31815 Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Fri, 5 Jun 2015 12:31:08 +0200 Subject: [PATCH 16/40] [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 0000000..6fb1260 --- /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 8832984..212ac31 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 93c8931..9358ae1 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 ad54f3d..b35afa1 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 3eba31423d8582bb92aabf6c771cd56af3d5212a Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Mon, 8 Jun 2015 11:13:41 +0200 Subject: [PATCH 17/40] [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 0000000..1c67daf --- /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 a350c1ec2592e105a629715f7db78d779cc6b7fd Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 9 Jun 2015 11:58:53 +0200 Subject: [PATCH 18/40] 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 212ac31..d54b072 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 cffec14a36ed8522d3a613fa75479f8f5aca1a7a Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Thu, 2 Apr 2015 10:56:50 +0200 Subject: [PATCH 19/40] [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 9358ae1..94bd49a 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 458cf67109d4eb808874f70b599301d4bc38a9b0 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Thu, 11 Jun 2015 09:03:47 +0200 Subject: [PATCH 20/40] [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 d54b072..ff7555d 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 0000000..8387f27 --- /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 67fc052269de870dfab0fe40a238a0bbd2162a0c Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Wed, 17 Jun 2015 12:32:34 +0200 Subject: [PATCH 21/40] [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 ff7555d..e81e2b5 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 f9a444503c2400140e35f07370cf003ce90588d5 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Fri, 26 Jun 2015 16:02:10 +0200 Subject: [PATCH 22/40] [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 94bd49a..9358ae1 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 c73d1ec3169c3ed0bdf16cd07192b665193b0d8c Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Tue, 1 Sep 2015 12:20:23 -0400 Subject: [PATCH 23/40] 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 0000000..8084e16 --- /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 0000000..174f8f5 --- /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 0000000..0125fee --- /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 0000000..866c553 --- /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 0000000..35482cc --- /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 0000000..de6cae2 --- /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 87dc5ec328e0315bc21a30a7d30f7f2d0277616d 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/40] [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 e81e2b5..329859e 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 afa125d8be8a551dcf216e9dff6ac6caa2c2fc26 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 10 Oct 2015 21:23:01 -0400 Subject: [PATCH 25/40] 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 329859e..275bff9 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 8084e16..12bde78 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 7117737cea69409ede1f888ef5e03caa44c2f73f Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 6 Oct 2016 14:47:55 +0200 Subject: [PATCH 26/40] [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 c3ed65b95a3a2846b11d1b29bb7665f15987cd4c Mon Sep 17 00:00:00 2001 From: Ilyas Date: Wed, 18 Nov 2015 14:50:48 +0500 Subject: [PATCH 27/40] 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 275bff9..329859e 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 9358ae1..0a82d5f 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 b830eae9321d0be0c982ea9fe916cc2963ee6752 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 3 Jun 2016 16:04:20 +0200 Subject: [PATCH 28/40] [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 6fb1260..cc06cc1 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 fb5e0c3..a0fdc10 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 329859e..7e02544 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 8387f27..3a7a352 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 0000000..5dfe830 --- /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 0a82d5f..c05ee73 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,15 +5,11 @@ import StringIO from openerp import api, models from openerp.tools.translate import _ -from openerp.exceptions import Warning +from openerp.exceptions import Warning as UserError -_logger = logging.getLogger(__name__) +from .ofx import OfxParser, OfxParser_ok -try: - from ofxparse import OfxParser as ofxparser -except ImportError: - _logger.warn("ofxparse not found, OFX parsing disabled.") - ofxparser = None +_logger = logging.getLogger(__name__) class AccountBankStatementImport(models.TransientModel): @@ -21,11 +17,12 @@ class AccountBankStatementImport(models.TransientModel): @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 0000000..d746938 --- /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 15a0140..9ce25a7 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 b35afa1..0efe690 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 0000000..3f0892f --- /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 a2e552cf9271c208141ec3ef544ebb3c6347b3cd Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 14 Nov 2016 17:21:14 +0100 Subject: [PATCH 29/40] [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 cc06cc1..3262208 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 a0fdc10..02baef4 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 7e02544..df4f07f 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 3a7a352..0000000 --- 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 c05ee73..0000000 --- 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 d746938..0000000 --- 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 0efe690..4b5c1e5 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 3f0892f..046ed1e 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 0000000..4835be7 --- /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 5200fc7f0df791de1528944956e1b166f1d9297d Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Fri, 16 Dec 2016 19:13:46 -0500 Subject: [PATCH 30/40] 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 0125fee..817837d 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 866c553..58d99df 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 35482cc..53d1866 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 12bde78..05c7816 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 de6cae2..9df1080 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 ee7330ae87a4cfeb28fa592cec28ec771bd5b3ed Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 18 Mar 2017 17:41:20 +0100 Subject: [PATCH 31/40] [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 4b5c1e5..4f01a6a 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 4835be7..e439bba 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 800047b1a8848f13e5c4632b1c462800c8505ffb Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Fri, 24 Mar 2017 21:10:43 -0400 Subject: [PATCH 32/40] 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 0000000..bf74b0c --- /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 0000000..f573e12 --- /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 817837d..6f84da8 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 0000000..147e888 --- /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 0000000..d8ec0d4 --- /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 58d99df..297d15c 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 0000000..e81a792 --- /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 53d1866..74b421b 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 05c7816..7e5f191 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 0000000..4d00797 --- /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 9df1080..710065e 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 e941f0dfddde31f53abb9b3f08acbb0a6ce32bc3 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 29 Mar 2017 16:26:52 +0200 Subject: [PATCH 33/40] 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 e439bba..50ba61f 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 b9c924fa728451ec1716a20f1bb05170158ea226 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 11 Apr 2017 23:01:16 +0200 Subject: [PATCH 34/40] [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 50ba61f..e063d45 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 3cc3ac995d12075544c6a3cf32126bc859a69d4c Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Mon, 1 May 2017 16:50:16 +0200 Subject: [PATCH 35/40] 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 bf74b0c..d178693 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 6f84da8..9ce95ee 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 297d15c..dd03ac3 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 74b421b..bef900f 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 7e5f191..325d5d2 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 710065e..f906c95 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 f8255d469f42edb9225131d09b947e1ac48794b0 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Thu, 18 Jan 2018 14:34:51 +0100 Subject: [PATCH 36/40] [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 3262208..8435430 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 02baef4..4027237 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 df4f07f..d4305e7 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 9ce25a7..bb3456a 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 4f01a6a..095dd70 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 0000000..99c0161 --- /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 0000000..b9e64a3 --- /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 5dfe830..7dafcd1 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 e063d45..4258759 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 46ef62d1d224515741eeb2852b03009bfae15547 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Thu, 11 Oct 2018 20:42:01 +0000 Subject: [PATCH 37/40] [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 1c67daf..7c267d2 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 1059bf6b3e0ecc55859eee67c935b5370be23076 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/40] [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 4258759..8944add 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 f4082fa857d8f44c0ed87f1f3575ccf5376eb4fb Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sun, 2 Dec 2018 02:33:37 +0000 Subject: [PATCH 39/40] 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 d178693..3f881f9 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 174f8f5..0e5c330 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 f573e12..6617a1d 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 9ce95ee..3e504e9 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 147e888..f13f142 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 d8ec0d4..9147efa 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 dd03ac3..45d0b47 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 e81a792..06acf96 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 bef900f..96f25a0 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 325d5d2..028e2eb 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 4d00797..8038174 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 f906c95..4c90d8d 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 fb19ad3dc033226fe65c8652dde6a9b41d181e5b 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/40] [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 8435430..48ce1f7 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 4027237..9b42961 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 d4305e7..d1131d4 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 0000000..e18569e --- /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 0000000..83c5fb5 --- /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 095dd70..5bbf923 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(