From f91d8293db6419482b6f6a2888c9fb6817e987b0 Mon Sep 17 00:00:00 2001 From: Magno Costa Date: Wed, 19 Jun 2024 13:36:14 -0300 Subject: [PATCH] [FIX] l10n_br_sale_stock: Tests of 'Lucro Presumido' need to inform Payment Mode when the module l10n_br_account_nfe are installed like CI case, necessary to avoid error. --- l10n_br_sale_stock/tests/test_sale_stock.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/l10n_br_sale_stock/tests/test_sale_stock.py b/l10n_br_sale_stock/tests/test_sale_stock.py index 6e991d9f08ab..b636f354df50 100644 --- a/l10n_br_sale_stock/tests/test_sale_stock.py +++ b/l10n_br_sale_stock/tests/test_sale_stock.py @@ -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):