-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_br_cte: add make pdf tests
- Loading branch information
1 parent
078c7e6
commit 81facab
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2024 - TODAY, Marcel Savegnago <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.exceptions import UserError | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestDacteGeneration(TransactionCase): | ||
def setUp(self): | ||
super().setUp() | ||
|
||
def test_generate_dacte_brazil_fiscal_report(self): | ||
cte = self.env.ref("l10n_br_cte.demo_cte_lc_modal_rodoviario") | ||
cte.action_document_confirm() | ||
cte.view_pdf() | ||
|
||
self.assertTrue(cte.file_report_id) | ||
|
||
def test_generate_dacte_document_type_error(self): | ||
dacte_report = self.env["ir.actions.report"].search( | ||
[("report_name", "=", "main_template_dacte")] | ||
) | ||
cte = self.env.ref("l10n_br_cte.demo_cte_lc_modal_rodoviario") | ||
cte.document_type_id = self.env.ref("l10n_br_fiscal.document_01") | ||
cte.action_document_confirm() | ||
with self.assertRaises(UserError) as captured_exception: | ||
dacte_report._render_qweb_pdf([cte.id]) | ||
self.assertEqual( | ||
captured_exception.exception.args[0], | ||
"You can only print a DACTE of a CTe(57).", | ||
) | ||
|
||
def test_generate_dacte_brazil_fiscal_report_partner(self): | ||
cte = self.env.ref("l10n_br_cte.demo_cte_lc_modal_rodoviario") | ||
cte.action_document_confirm() | ||
cte.issuer = "partner" | ||
cte.view_pdf() | ||
|
||
self.assertTrue(cte.file_report_id) |