Browse Source

camt: allow modules to enhance the parser

pull/110/head
Louis Bettens 8 years ago
parent
commit
8c59a4e014
  1. 1
      account_bank_statement_import_camt/__init__.py
  2. 1
      account_bank_statement_import_camt/models/__init__.py
  3. 3
      account_bank_statement_import_camt/models/account_bank_statement_import.py
  4. 5
      account_bank_statement_import_camt/models/parser.py

1
account_bank_statement_import_camt/__init__.py

@ -2,4 +2,3 @@
# © 2013-2016 Therp BV <http://therp.nl> # © 2013-2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models
from . import camt

1
account_bank_statement_import_camt/models/__init__.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2013-2016 Therp BV <http://therp.nl> # © 2013-2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import parser
from . import account_bank_statement_import from . import account_bank_statement_import

3
account_bank_statement_import_camt/models/account_bank_statement_import.py

@ -6,7 +6,6 @@ import logging
import StringIO import StringIO
import zipfile import zipfile
from openerp import api, models from openerp import api, models
from ..camt import CamtParser as Parser
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@ -19,7 +18,7 @@ class AccountBankStatementImport(models.TransientModel):
def _parse_file(self, data_file): def _parse_file(self, data_file):
"""Parse a CAMT053 XML file.""" """Parse a CAMT053 XML file."""
try: try:
parser = Parser()
parser = self.env['account.bank.statement.import.camt.parser']
_logger.debug("Try parsing with camt.") _logger.debug("Try parsing with camt.")
return parser.parse(data_file) return parser.parse(data_file)
except ValueError: except ValueError:

5
account_bank_statement_import_camt/camt.py → account_bank_statement_import_camt/models/parser.py

@ -5,8 +5,11 @@
import re import re
from lxml import etree from lxml import etree
from openerp import models
class CamtParser(object):
class CamtParser(models.AbstractModel):
_name = 'account.bank.statement.import.camt.parser'
"""Parser for camt bank statement import files.""" """Parser for camt bank statement import files."""
def parse_amount(self, ns, node): def parse_amount(self, ns, node):
Loading…
Cancel
Save