Skip to content

Commit

Permalink
[FIX] Corrige tipo de imposto do cnab, adiciona mensagem quando não p…
Browse files Browse the repository at this point in the history
…uder fazer parse do arquivo
  • Loading branch information
danimaribeiro committed Nov 20, 2018
1 parent 01731b3 commit 959265f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions br_account_payment/wizard/payment_cnab_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion br_payment_cnab/models/payment_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 959265f

Please sign in to comment.