mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[FIX] Prevent unneeded processing and memory use in parsers.
This commit is contained in:
@@ -20,11 +20,10 @@
|
||||
##############################################################################
|
||||
import logging
|
||||
from openerp import models
|
||||
from openerp.addons.bank_statement_parse.parserlib import convert_statements
|
||||
from .mt940 import MT940Parser as Parser
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AccountBankStatementImport(models.TransientModel):
|
||||
@@ -35,10 +34,10 @@ class AccountBankStatementImport(models.TransientModel):
|
||||
"""Parse a MT940 IBAN ING file."""
|
||||
parser = Parser()
|
||||
try:
|
||||
_logger.debug("Try parsing with MT940 IBAN ING.")
|
||||
return convert_statements(parser.parse(data_file))
|
||||
_LOGGER.debug("Try parsing with MT940 IBAN ING.")
|
||||
return parser.parse(data_file)
|
||||
except ValueError:
|
||||
# Returning super will call next candidate:
|
||||
_logger.debug("Statement file was not a MT940 IBAN ING file.")
|
||||
_LOGGER.debug("Statement file was not a MT940 IBAN ING file.")
|
||||
return super(AccountBankStatementImport, self)._parse_file(
|
||||
cr, uid, data_file, context=context)
|
||||
|
||||
@@ -63,7 +63,7 @@ class TestStatementFile(TransactionCase):
|
||||
(statement_obj.balance_start, start_balance)
|
||||
)
|
||||
self.assertTrue(
|
||||
abs(statement_obj.balance_end - end_balance) < 0.00001,
|
||||
abs(statement_obj.balance_end_real - end_balance) < 0.00001,
|
||||
'Start balance %f not equal to expected %f' %
|
||||
(statement_obj.balance_end_real, end_balance)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user