Browse Source

add import tool ofx

pull/57/head
stephane lerendu 9 years ago
parent
commit
5e0a8337d4
  1. 1
      account_bank_statement_import_ofx/README.rst
  2. 28
      account_bank_statement_import_ofx/__openerp__.py
  3. 8
      account_bank_statement_import_ofx/account_bank_statement_import_ofx.py
  4. 7
      account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx

1
account_bank_statement_import_ofx/README.rst

@ -46,6 +46,7 @@ Contributors
* Alexis de Lattre <alexis@via.ecp.fr> * Alexis de Lattre <alexis@via.ecp.fr>
* Laurent Mignon <laurent.mignon@acsone.eu> * Laurent Mignon <laurent.mignon@acsone.eu>
* Ronald Portier <rportier@therp.nl> * Ronald Portier <rportier@therp.nl>
* Stephane Lerendu <stephane.lerendu@mind-and-go.com>
Maintainer Maintainer
---------- ----------

28
account_bank_statement_import_ofx/__openerp__.py

@ -1,4 +1,30 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
##############################################################################
#
# Module : account_bank_statement_import_ofx
# Modified : 2016-01-28 : Stephane LERENDU <stephane.lerendu@mind-and-go.com>
# Approbation Florent THOMAS <florent.thomas@mind-and-go.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{ {
'name': 'Import OFX Bank Statement', 'name': 'Import OFX Bank Statement',
'category': 'Banking addons', 'category': 'Banking addons',
@ -16,5 +42,5 @@
'python': ['ofxparse'], 'python': ['ofxparse'],
}, },
'auto_install': False, 'auto_install': False,
'installable': False,
'installable': True,
} }

8
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 # (normal behavious is to provide 'account_number', which the
# generic module uses to find partner/bank) # generic module uses to find partner/bank)
bank_account_id = partner_id = False 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: if banks:
bank_account = banks[0] bank_account = banks[0]
bank_account_id = bank_account.id bank_account_id = bank_account.id
@ -63,6 +66,7 @@ class AccountBankStatementImport(models.TransientModel):
} }
total_amt += float(transaction.amount) total_amt += float(transaction.amount)
transactions.append(vals_line) transactions.append(vals_line)
except Exception, e: except Exception, e:
raise Warning(_("The following problem occurred during import. " raise Warning(_("The following problem occurred during import. "
"The file might not be valid.\n\n %s" % e.message)) "The file might not be valid.\n\n %s" % e.message))

7
account_bank_statement_import_ofx/test_ofx_file/test_ofx.ofx

@ -19,7 +19,7 @@
<SEVERITY>INFO</SEVERITY> <SEVERITY>INFO</SEVERITY>
</STATUS> </STATUS>
<STMTRS> <STMTRS>
<CURDEF>USD</CURDEF>
<CURDEF>EUR</CURDEF>
<BANKACCTFROM> <BANKACCTFROM>
<BANKID>000000123</BANKID> <BANKID>000000123</BANKID>
<ACCTID>123456</ACCTID> <ACCTID>123456</ACCTID>
@ -31,7 +31,8 @@
<STMTTRN> <STMTTRN>
<TRNTYPE>POS</TRNTYPE> <TRNTYPE>POS</TRNTYPE>
<DTPOSTED>20130824080000</DTPOSTED> <DTPOSTED>20130824080000</DTPOSTED>
<TRNAMT>-80</TRNAMT>
<TRNAMT>80</TRNAMT>
<!--<TRNAMT>-80</TRNAMT>-->
<FITID>219378</FITID> <FITID>219378</FITID>
<NAME>Agrolait</NAME> <NAME>Agrolait</NAME>
</STMTTRN> </STMTTRN>
@ -84,7 +85,7 @@
<SEVERITY>INFO</SEVERITY> <SEVERITY>INFO</SEVERITY>
</STATUS> </STATUS>
<CCSTMTRS> <CCSTMTRS>
<CURDEF>USD</CURDEF>
<CURDEF>EUR</CURDEF>
<CCACCTFROM> <CCACCTFROM>
<ACCTID>123412341234</ACCTID> <ACCTID>123412341234</ACCTID>
</CCACCTFROM> </CCACCTFROM>

Loading…
Cancel
Save