Browse Source
[REF] OCA convention;
[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;pull/80/head
Sylvain LE GAL
9 years ago
committed by
Pedro M. Baeza
11 changed files with 116 additions and 48 deletions
-
21account_bank_statement_import_ofx/README.rst
-
5account_bank_statement_import_ofx/__init__.py
-
15account_bank_statement_import_ofx/__manifest__.py
-
42account_bank_statement_import_ofx/demo/demo_data.xml
-
2account_bank_statement_import_ofx/models/__init__.py
-
21account_bank_statement_import_ofx/models/account_bank_statement_import.py
-
40account_bank_statement_import_ofx/models/ofx.py
-
4account_bank_statement_import_ofx/tests/__init__.py
-
2account_bank_statement_import_ofx/tests/test_import_bank_statement.py
-
0account_bank_statement_import_ofx/tests/test_ofx_file/test_ofx.ofx
-
12account_bank_statement_import_ofx/views/view_account_bank_statement_import.xml
@ -1,3 +1,2 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
|
|||
from . import account_bank_statement_import_ofx |
|||
# -*- coding: utf-8 -*- |
|||
from . import models |
@ -1,27 +1,23 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
<odoo> |
|||
|
|||
<record id="ofx_bank_journal" model="account.journal"> |
|||
<field name="name">Bank Journal - (test ofx)</field> |
|||
<field name="code">TBNKOFX</field> |
|||
<field name="type">bank</field> |
|||
<field name="sequence_id" ref="account.sequence_bank_journal"/> |
|||
<field name="default_debit_account_id" ref="account.usd_bnk"/> |
|||
<field name="default_credit_account_id" ref="account.usd_bnk"/> |
|||
<field name="user_id" ref="base.user_root"/> |
|||
<field name="currency" ref="base.USD"/> |
|||
</record> |
|||
<record id="ofx_sequence" model="ir.sequence"> |
|||
<field name="name">Bank Journal - (test ofx)</field> |
|||
<field name="prefix">OFX/%(range_year)s/</field> |
|||
<field name="implementation">no_gap</field> |
|||
<field name="padding">4</field> |
|||
<field name="use_date_range">1</field> |
|||
</record> |
|||
|
|||
<record id="ofx_company_bank" model="res.partner.bank"> |
|||
<field name="owner_name">Your Company</field> |
|||
<field name="acc_number">123456</field> |
|||
<field name="partner_id" ref="base.partner_root"></field> |
|||
<field name="company_id" ref="base.main_company"></field> |
|||
<field name="journal_id" ref="ofx_bank_journal"></field> |
|||
<field name="state">bank</field> |
|||
<field name="bank" ref="base.res_bank_1"/> |
|||
</record> |
|||
</data> |
|||
|
|||
</openerp> |
|||
<record id="ofx_bank_journal" model="account.journal"> |
|||
<field name="name">Bank Journal - (test ofx)</field> |
|||
<field name="bank_acc_number">123456</field> |
|||
<field name="code">TBNKOFX</field> |
|||
<field name="type">bank</field> |
|||
<field name="sequence_id" ref="ofx_sequence"/> |
|||
<field name="user_id" ref="base.user_root"/> |
|||
<field name="currency_id" ref="base.USD"/> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import account_bank_statement_import |
@ -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) |
@ -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 |
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" ?> |
|||
<odoo> |
|||
<record id="view_account_bank_statement_import_form" model="ir.ui.view"> |
|||
<field name="model">account.bank.statement.import</field> |
|||
<field name="inherit_id" ref="account_bank_statement_import.account_bank_statement_import_view"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//ul[@id='statement_format']" position="inside"> |
|||
<li>Open Financial Exchange (.OFX Money)</li> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue