Skip to content

Commit

Permalink
Merge PR #3255 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by rvalyi
  • Loading branch information
OCA-git-bot committed Aug 1, 2024
2 parents 65faa91 + 9ca0eb3 commit 0b9a5b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion l10n_br_nfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,9 @@ def make_pdf(self):
"type": "binary",
}
report = self.env.ref("l10n_br_nfe.report_danfe")
pdf_data = report._render_qweb_pdf(self.fiscal_line_ids.document_id.ids)
pdf_data = report._render_qweb_pdf(
"l10n_br_nfe.main_template_danfe", self.fiscal_line_ids.document_id.ids
)
attachment_data["datas"] = base64.b64encode(pdf_data[0])
file_pdf = self.file_report_id
self.file_report_id = False
Expand Down
13 changes: 6 additions & 7 deletions l10n_br_nfe/report/ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ def temp_xml_autorizacao(self, xml_string):
new_root.append(protNFe_node)
return etree.tostring(new_root)

def _render_qweb_html(self, res_ids, data=None):
if self.report_name == "main_template_danfe":
def _render_qweb_html(self, report_ref, res_ids, data=None):
if report_ref == "l10n_br_nfe.main_template_danfe":
return

return super()._render_qweb_html(res_ids, data=data)
return super()._render_qweb_html(report_ref, res_ids, data=data)

def _render_qweb_pdf(self, res_ids, data=None):
if self.report_name not in ["main_template_danfe"]:
return super()._render_qweb_pdf(res_ids, data=data)
def _render_qweb_pdf(self, report_ref, res_ids, data=None):
if report_ref not in ["l10n_br_nfe.main_template_danfe"]:
return super()._render_qweb_pdf(report_ref, res_ids, data=data)

nfe = self.env["l10n_br_fiscal.document"].search([("id", "in", res_ids)])

return self._render_danfe(nfe)

def _render_danfe(self, nfe):
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_nfe/tests/test_nfe_danfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_generate_danfe_document_type_error(self):
nfe.document_type_id = self.env.ref("l10n_br_fiscal.document_01")
nfe.action_document_confirm()
with self.assertRaises(UserError) as captured_exception:
danfe_report._render_qweb_pdf([nfe.id])
danfe_report._render_qweb_pdf("l10n_br_nfe.main_template_danfe", [nfe.id])
self.assertEqual(
captured_exception.exception.args[0],
"You can only print a DANFE of a NFe(55).",
Expand Down

0 comments on commit 0b9a5b9

Please sign in to comment.