diff --git a/br_account_payment/wizard/payment_cnab_import.py b/br_account_payment/wizard/payment_cnab_import.py index 31eff82e3..4ca9ed14b 100644 --- a/br_account_payment/wizard/payment_cnab_import.py +++ b/br_account_payment/wizard/payment_cnab_import.py @@ -2,10 +2,12 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import base64 - +import logging from odoo import fields, models from odoo.exceptions import UserError +_logger = logging.getLogger(__name__) + class l10nBrPaymentCnabImport(models.TransientModel): _name = 'l10n_br.payment.cnab.import' @@ -38,8 +40,15 @@ def do_import(self, cnab_file): pass def action_import_cnab(self): - cnab = base64.decodestring(self.cnab_file) - acc_number, bra_number = self._get_account(cnab) - - self.validate_journal(acc_number, bra_number) - return self.do_import(cnab) + try: + cnab = base64.decodestring(self.cnab_file) + acc_number, bra_number = self._get_account(cnab) + + self.validate_journal(acc_number, bra_number) + return self.do_import(cnab) + except UserError: + raise + except Exception as e: + _logger.error(str(e), exc_info=True) + msg = 'O arquivo importado não parece ser o correto:\n%s' % str(e) + raise UserError(msg) diff --git a/br_payment_cnab/models/payment_information.py b/br_payment_cnab/models/payment_information.py index d167ac2dc..0abbeae56 100644 --- a/br_payment_cnab/models/payment_information.py +++ b/br_payment_cnab/models/payment_information.py @@ -181,4 +181,4 @@ def _compute_tax_identification(self): for item in self: if item.payment_type not in ('05', '06', '07', '09'): continue - return TAX_IDENTIFICATION.get(item.payment_type) + item.tax_identification = TAX_IDENTIFICATION.get(item.payment_type)