diff --git a/l10n_br_mdfe/demo/fiscal_document_demo.xml b/l10n_br_mdfe/demo/fiscal_document_demo.xml index cc5328f4f269..a3d7df3edec8 100644 --- a/l10n_br_mdfe/demo/fiscal_document_demo.xml +++ b/l10n_br_mdfe/demo/fiscal_document_demo.xml @@ -1,6 +1,14 @@ + + + + + 41190806117473000150550010000586251016759484 @@ -8,9 +16,10 @@ 33.19 + - + + + + + Manifesto + + 0 + 1 + out + + + + + - + + + + + Manifesto + + 0 + 1 + out + + + + + - + + + + + Manifesto + + 0 + 1 + out + + + + + - + + + + + Manifesto + + 0 + 1 + out + + + + diff --git a/l10n_br_mdfe/report/ir_actions_report.py b/l10n_br_mdfe/report/ir_actions_report.py index cfa52ef9a342..1698603f88c1 100644 --- a/l10n_br_mdfe/report/ir_actions_report.py +++ b/l10n_br_mdfe/report/ir_actions_report.py @@ -29,7 +29,7 @@ def _render_qweb_pdf(self, res_ids, data=None): def _render_damdfe(self, mdfe): if mdfe.document_type != "58": - raise UserError(_("You can only print a DAMDFE of a MDF-e(58).")) + raise UserError(_("You can only print a DAMDFE of a MDFe(58).")) mdfe_xml = False if mdfe.authorization_file_id: diff --git a/l10n_br_mdfe/tests/__init__.py b/l10n_br_mdfe/tests/__init__.py index bfd6ae80ae57..8e2700191841 100644 --- a/l10n_br_mdfe/tests/__init__.py +++ b/l10n_br_mdfe/tests/__init__.py @@ -4,3 +4,4 @@ from . import test_mdfe_import from . import test_mdfe_structure from . import test_mdfe_res_partner +from . import test_mdfe_damdfe diff --git a/l10n_br_mdfe/tests/test_mdfe_damdfe.py b/l10n_br_mdfe/tests/test_mdfe_damdfe.py new file mode 100644 index 000000000000..180a87071780 --- /dev/null +++ b/l10n_br_mdfe/tests/test_mdfe_damdfe.py @@ -0,0 +1,39 @@ +# Copyright 2024 - TODAY, Marcel Savegnago +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.exceptions import UserError +from odoo.tests.common import TransactionCase + + +class TestDamdfeGeneration(TransactionCase): + def setUp(self): + super().setUp() + + def test_generate_damdfe_brazil_fiscal_report(self): + mdfe = self.env.ref("l10n_br_mdfe.demo_mdfe_lc_modal_rodoviario") + mdfe.action_document_confirm() + mdfe.view_pdf() + + self.assertTrue(mdfe.file_report_id) + + def test_generate_damdfe_document_type_error(self): + damdfe_report = self.env["ir.actions.report"].search( + [("report_name", "=", "main_template_damdfe")] + ) + mdfe = self.env.ref("l10n_br_mdfe.demo_mdfe_lc_modal_rodoviario") + mdfe.document_type_id = self.env.ref("l10n_br_fiscal.document_01") + mdfe.action_document_confirm() + with self.assertRaises(UserError) as captured_exception: + damdfe_report._render_qweb_pdf([mdfe.id]) + self.assertEqual( + captured_exception.exception.args[0], + "You can only print a DAMDFE of a MDFe(58).", + ) + + def test_generate_damdfe_brazil_fiscal_report_partner(self): + mdfe = self.env.ref("l10n_br_mdfe.demo_mdfe_lc_modal_rodoviario") + mdfe.action_document_confirm() + mdfe.issuer = "partner" + mdfe.view_pdf() + + self.assertTrue(mdfe.file_report_id)