Browse Source

Skip lines with amount = 0 (blocker for this bank: www.banque-rhone-alpes.fr)

Use account number instead of bank number as 'name' (sync with code in v8)
Update import lines
pull/70/head^2
Alexis de Lattre 8 years ago
parent
commit
16357ebcf6
  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 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
@ -35,8 +35,16 @@ class AccountBankStatementImport(models.TransientModel):
transactions = []
total_amt = 0.00
precision = self.env['decimal.precision'].precision_get('Account')
try:
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
# to find res.partner and res.partner.bank here
# (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))
vals_bank_statement = {
'name': ofx.account.routing_number,
'name': ofx.account.number,
'transactions': transactions,
'balance_start': ofx.account.statement.balance,
'balance_end_real':

Loading…
Cancel
Save