Browse Source

Merge pull request #1 from akretion/9sylvain-ofx-small-improvements

[9.0] OFX Skip lines with amount = 0 (blocker for this bank: www.banque-rhone-alpes.fr)
pull/70/head
Sylvain LE GAL 8 years ago
committed by GitHub
parent
commit
9c47a9cb55
  1. 16
      account_bank_statement_import_ofx/models/account_bank_statement_import.py

16
account_bank_statement_import_ofx/models/account_bank_statement_import.py

@ -3,9 +3,9 @@
import logging import logging
import StringIO import StringIO
from openerp import api, models
from openerp.tools.translate import _
from openerp.exceptions import Warning as UserError
from openerp import api, models, _
from openerp.exceptions import UserError
from openerp.tools import float_is_zero
from .ofx import OfxParser, OfxParser_ok from .ofx import OfxParser, OfxParser_ok
@ -35,8 +35,16 @@ class AccountBankStatementImport(models.TransientModel):
transactions = [] transactions = []
total_amt = 0.00 total_amt = 0.00
precision = self.env['decimal.precision'].precision_get('Account')
try: try:
for transaction in ofx.account.statement.transactions: for transaction in ofx.account.statement.transactions:
# 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
if float_is_zero(
float(transaction.amount), precision_digits=precision):
continue
# Since ofxparse doesn't provide account numbers, we'll have # Since ofxparse doesn't provide account numbers, we'll have
# to find res.partner and res.partner.bank here # to find res.partner and res.partner.bank here
# (normal behavious is to provide 'account_number', which the # (normal behavious is to provide 'account_number', which the
@ -65,7 +73,7 @@ class AccountBankStatementImport(models.TransientModel):
"The file might not be valid.\n\n %s" % e.message)) "The file might not be valid.\n\n %s" % e.message))
vals_bank_statement = { vals_bank_statement = {
'name': ofx.account.routing_number,
'name': ofx.account.number,
'transactions': transactions, 'transactions': transactions,
'balance_start': ofx.account.statement.balance, 'balance_start': ofx.account.statement.balance,
'balance_end_real': 'balance_end_real':

Loading…
Cancel
Save