diff --git a/l10n_br_account_nfe/models/document.py b/l10n_br_account_nfe/models/document.py index daadf9786e0f..89de0a6aab79 100644 --- a/l10n_br_account_nfe/models/document.py +++ b/l10n_br_account_nfe/models/document.py @@ -152,14 +152,15 @@ def _check_fiscal_payment_mode(self): if not rec.move_ids.payment_mode_id.fiscal_payment_mode: raise UserError( _( - f"Payment Mode {rec.move_ids.payment_mode_id.name} should has " - "has Fiscal Payment Mode filled to be used in Fiscal Document!" + "Payment Mode %(mode)s should have " + "a Fiscal Payment Mode filled to be used in the Fiscal Document!", + mode=rec.move_ids.payment_mode_id.name, ) ) def _update_nfce_for_offline_contingency(self): - super()._update_nfce_for_offline_contingency() - + res = super()._update_nfce_for_offline_contingency() if self.move_ids: copy_invoice = self.move_ids[0].copy() copy_invoice.action_post() + return res diff --git a/l10n_br_account_nfe/tests/test_nfce_contingency.py b/l10n_br_account_nfe/tests/test_nfce_contingency.py index cfa0f812be87..42a87bff979f 100644 --- a/l10n_br_account_nfe/tests/test_nfce_contingency.py +++ b/l10n_br_account_nfe/tests/test_nfce_contingency.py @@ -3,11 +3,18 @@ from odoo.tests import TransactionCase +from odoo.addons.spec_driven_model import hooks -class TestAccountNFCe(TransactionCase): + +class TestAccountNFCeContingency(TransactionCase): def setUp(self): super().setUp() - + # this hook is required to test l10n_br_account_nfe alone: + hooks.register_hook( + self.env, + "l10n_br_nfe", + "odoo.addons.l10n_br_nfe_spec.models.v4_0.leiaute_nfe_v4_00", + ) self.document_id = self.env.ref("l10n_br_nfe.demo_nfce_same_state") self.prepare_account_move_nfce() @@ -64,5 +71,4 @@ def prepare_account_move_nfce(self): def test_nfce_contingencia(self): self.document_id._update_nfce_for_offline_contingency() - self.assertIn(self.document_move_id, self.document_id.move_ids) diff --git a/l10n_br_account_nfe/tests/test_nfe_danfe_account.py b/l10n_br_account_nfe/tests/test_nfe_danfe_account.py index b5e54d503a69..31c2dab2a59a 100644 --- a/l10n_br_account_nfe/tests/test_nfe_danfe_account.py +++ b/l10n_br_account_nfe/tests/test_nfe_danfe_account.py @@ -6,7 +6,7 @@ @tagged("post_install", "-at_install") -class TestGeneratePaymentInfo(SavepointCase): +class TestDanfe(SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py b/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py index c5a287b1f2f3..219658d01042 100644 --- a/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py +++ b/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py @@ -142,7 +142,6 @@ def setUpClass(cls): check_move_validity=False )._onchange_fiscal_operation_line_id() line.with_context(check_move_validity=False)._onchange_fiscal_tax_ids() - cls.invoice_demo_data.action_post() def test_nfe_generate_tag_pag(self): """Test NFe generate TAG PAG.""" @@ -192,8 +191,15 @@ def test_payment_mode_without_fiscal_mode(self): } ) self.invoice_demo_data.payment_mode_id = self.pay_mode.id - with self.assertRaises(UserError): + with self.assertRaises(UserError) as captured_exception: self.invoice_demo_data.action_post() + self.assertEqual( + captured_exception.exception.args[0], + ( + "Payment Mode Sem Meio Fiscal should have a " + "Fiscal Payment Mode filled to be used in the Fiscal Document!" + ), + ) def test_invoice_without_payment_mode(self): """Test Invoice without Payment Mode.""" diff --git a/l10n_br_account_nfe/tests/test_nfe_with_ipi.py b/l10n_br_account_nfe/tests/test_nfe_with_ipi.py index bad4005b539f..a792623680fc 100644 --- a/l10n_br_account_nfe/tests/test_nfe_with_ipi.py +++ b/l10n_br_account_nfe/tests/test_nfe_with_ipi.py @@ -4,7 +4,7 @@ @tagged("post_install", "-at_install") -class TestAccountAccount(AccountMoveBRCommon): +class TestNFeWithIPI(AccountMoveBRCommon): @classmethod def setUpClass(cls, chart_template_ref=None): super().setUpClass(chart_template_ref) @@ -35,7 +35,7 @@ def setUpClass(cls, chart_template_ref=None): post=False, ) cls.move_out_venda.payment_mode_id = cls.payment_mode - cls.move_out_venda.post() + cls.move_out_venda.action_post() def test_nfe_with_ipi(self): """