From 8c59a4e014f7e955de58eb59d2769a4f3e7f6d86 Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Fri, 21 Apr 2017 14:31:50 +0200 Subject: [PATCH] camt: allow modules to enhance the parser --- account_bank_statement_import_camt/__init__.py | 1 - account_bank_statement_import_camt/models/__init__.py | 1 + .../models/account_bank_statement_import.py | 3 +-- .../{camt.py => models/parser.py} | 5 ++++- 4 files changed, 6 insertions(+), 4 deletions(-) rename account_bank_statement_import_camt/{camt.py => models/parser.py} (98%) diff --git a/account_bank_statement_import_camt/__init__.py b/account_bank_statement_import_camt/__init__.py index 6350c71..1eb5270 100644 --- a/account_bank_statement_import_camt/__init__.py +++ b/account_bank_statement_import_camt/__init__.py @@ -2,4 +2,3 @@ # © 2013-2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models -from . import camt diff --git a/account_bank_statement_import_camt/models/__init__.py b/account_bank_statement_import_camt/models/__init__.py index 44b3362..0251c8f 100644 --- a/account_bank_statement_import_camt/models/__init__.py +++ b/account_bank_statement_import_camt/models/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- # © 2013-2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import parser from . import account_bank_statement_import diff --git a/account_bank_statement_import_camt/models/account_bank_statement_import.py b/account_bank_statement_import_camt/models/account_bank_statement_import.py index 9d711d8..3040b95 100644 --- a/account_bank_statement_import_camt/models/account_bank_statement_import.py +++ b/account_bank_statement_import_camt/models/account_bank_statement_import.py @@ -6,7 +6,6 @@ import logging import StringIO import zipfile from openerp import api, models -from ..camt import CamtParser as Parser _logger = logging.getLogger(__name__) @@ -19,7 +18,7 @@ class AccountBankStatementImport(models.TransientModel): def _parse_file(self, data_file): """Parse a CAMT053 XML file.""" try: - parser = Parser() + parser = self.env['account.bank.statement.import.camt.parser'] _logger.debug("Try parsing with camt.") return parser.parse(data_file) except ValueError: diff --git a/account_bank_statement_import_camt/camt.py b/account_bank_statement_import_camt/models/parser.py similarity index 98% rename from account_bank_statement_import_camt/camt.py rename to account_bank_statement_import_camt/models/parser.py index d5fa82d..8e685b2 100644 --- a/account_bank_statement_import_camt/camt.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -5,8 +5,11 @@ import re 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.""" def parse_amount(self, ns, node):