# -*- coding: utf-8 -*- """Add process_camt method to account.bank.statement.import.""" ############################################################################## # # Copyright (C) 2013-2015 Therp BV # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ############################################################################## import logging from openerp import models _logger = logging.getLogger(__name__) class AccountBankStatementImport(models.TransientModel): """Add process_camt method to account.bank.statement.import.""" _inherit = 'account.bank.statement.import' def _parse_file(self, cr, uid, data_file, context=None): """Parse a CAMT053 XML file.""" parser = self.pool['account.bank.statement.import.camt.parser'] try: _logger.debug("Try parsing with camt.") return parser.parse(data_file) except ValueError: # Not a camt file, returning super will call next candidate: _logger.debug("Statement file was not a camt file.", exc_info=True) return super(AccountBankStatementImport, self)._parse_file( cr, uid, data_file, context=context)