From 5e0a8337d4ee7b23b124d8b03b1d68f4533964b8 Mon Sep 17 00:00:00 2001 From: stephane lerendu Date: Tue, 2 Feb 2016 16:41:39 +0100 Subject: [PATCH] add import tool ofx --- account_bank_statement_import_ofx/README.rst | 1 + .../__openerp__.py | 28 ++++++++++++++++++- .../account_bank_statement_import_ofx.py | 8 ++++-- .../test_ofx_file/test_ofx.ofx | 7 +++-- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/account_bank_statement_import_ofx/README.rst b/account_bank_statement_import_ofx/README.rst index 6fb1260..2f71da5 100644 --- a/account_bank_statement_import_ofx/README.rst +++ b/account_bank_statement_import_ofx/README.rst @@ -46,6 +46,7 @@ Contributors * Alexis de Lattre * Laurent Mignon * Ronald Portier +* Stephane Lerendu Maintainer ---------- diff --git a/account_bank_statement_import_ofx/__openerp__.py b/account_bank_statement_import_ofx/__openerp__.py index 275bff9..2cae13e 100644 --- a/account_bank_statement_import_ofx/__openerp__.py +++ b/account_bank_statement_import_ofx/__openerp__.py @@ -1,4 +1,30 @@ # -*- encoding: utf-8 -*- + +############################################################################## +# +# Module : account_bank_statement_import_ofx +# Modified : 2016-01-28 : Stephane LERENDU +# Approbation Florent THOMAS +# +# modification in the account_bank_statement_import_ofx.py file +# in the res.partner.bank object, I search partner_id field to have the name +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + { 'name': 'Import OFX Bank Statement', 'category': 'Banking addons', @@ -16,5 +42,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..9720ac6 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 @@ -45,8 +45,11 @@ class AccountBankStatementImport(models.TransientModel): # (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( - [('owner_name', '=', transaction.payee)], limit=1) + + # 2016-01-28 : Stephane LERENDU + # in the res.partner.bank object, I search partner_id field to have the name + banks = self.env['res.partner.bank'].search([('partner_id.name', '=', transaction.payee)], limit=1) + if banks: bank_account = banks[0] bank_account_id = bank_account.id @@ -63,6 +66,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. " "The file might not be valid.\n\n %s" % e.message)) 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..963ffba 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 @@ -19,7 +19,7 @@ INFO - USD + EUR 000000123 123456 @@ -31,7 +31,8 @@ POS 20130824080000 - -80 + 80 + 219378 Agrolait @@ -84,7 +85,7 @@ INFO - USD + EUR 123412341234