Skip to content

Commit

Permalink
[FIX] l10n_br_sale_stock: Tests of 'Lucro Presumido' need to inform P…
Browse files Browse the repository at this point in the history
…ayment Mode when the module l10n_br_account_nfe are installed like CI case, necessary to avoid error.
  • Loading branch information
mbcosta committed Jun 19, 2024
1 parent 0156e50 commit f91d829
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions l10n_br_sale_stock/tests/test_sale_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,24 @@ def test_lucro_presumido_company(self):
mv_line.tax_ids,
"Taxes in invoice lines are different from move lines.",
)
# Caso onde o l10n_br_account_nfe esta instalado, exemplo CI do
# github, retorna erro ao acionar o metodo action_post devido a
# validação do modulo:
# l10n_br_account_nfe/models/document.py", line 151,
# in _check_fiscal_payment_mode
# raise UserError(_("Payment Mode cannot be empty for this NF-e/NFC-e"))
# odoo.exceptions.UserError: Payment Mode cannot be empty for this
# NF-e/NFC-e
# Para evitar o problema é verificado se o campo existe e nesse caso
# preenche um valor para evitar o erro.
if hasattr(invoice, "payment_mode_id"):
payment_modes = self.env["account.payment.mode"].search(
[("company_id", "=", self.company_lucro_presumido.id)]
)
payment_mode = payment_modes[0]
payment_mode.fiscal_payment_mode = "15"
invoice.payment_mode_id = payment_mode

invoice.action_post()

def test_down_payment(self):
Expand Down

0 comments on commit f91d829

Please sign in to comment.