Skip to content

Commit

Permalink
Merge 959265f into 978d819
Browse files Browse the repository at this point in the history
  • Loading branch information
danimaribeiro committed Nov 20, 2018
2 parents 978d819 + 959265f commit ed6e3e0
Show file tree
Hide file tree
Showing 3 changed files with 25 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)
9 changes: 9 additions & 0 deletions br_account_voucher/models/account_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,12 @@ def voucher_move_line_create(self, line_total, move_id, company_currency,
line.analytic_tag_ids = [(6, False, line2.analytic_tag_ids.ids)]

return line_total

@api.multi
def first_move_line_get(self, move_id, company_currency, current_currency):
vals = super(AccountVoucher, self).first_move_line_get(
move_id, company_currency, current_currency)
# Correção do valor quando retenção - tax_amount é negativo
if self.tax_amount < 0.0:
vals['credit'] += self.tax_amount
return vals
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 ed6e3e0

Please sign in to comment.