Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ addon | version | maintainers | summary
[report_qweb_pdf_cover](report_qweb_pdf_cover/) | 16.0.1.0.0 | | Add front and back covers to your QWeb PDF reports
[report_qweb_pdf_watermark](report_qweb_pdf_watermark/) | 16.0.1.0.1 | | Add watermarks to your QWEB PDF reports
[report_qweb_signer](report_qweb_signer/) | 16.0.1.0.5 | | Sign Qweb PDFs usign a PKCS#12 certificate
[report_substitute](report_substitute/) | 16.0.1.1.1 | <a href='https://github.com/sbejaoui'><img src='https://github.com/sbejaoui.png' width='32' height='32' style='border-radius:50%;' alt='sbejaoui'/></a> | This module allows to create substitution rules for report actions.
[report_substitute](report_substitute/) | 16.0.1.1.2 | <a href='https://github.com/sbejaoui'><img src='https://github.com/sbejaoui.png' width='32' height='32' style='border-radius:50%;' alt='sbejaoui'/></a> | This module allows to create substitution rules for report actions.
[report_text_format_option](report_text_format_option/) | 16.0.1.0.0 | | Report Text Format Option
[report_wkhtmltopdf_param](report_wkhtmltopdf_param/) | 16.0.1.0.0 | | Add new parameters for a paper format to be used by wkhtmltopdf command as arguments.
[report_xlsx](report_xlsx/) | 16.0.2.0.2 | | Base module to create xlsx report
Expand Down
2 changes: 1 addition & 1 deletion report_substitute/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Report Substitute
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6e713ec7c433154ddfbdc2a954a61a5df2fcdabf03d875d3b3dd5bd0ce4ff980
!! source digest: sha256:308f4cd2414839b00119166f359a14cc6430df7ee469e2069829e683b8a464c6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion report_substitute/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"summary": """
This module allows to create substitution rules for report actions.
""",
"version": "16.0.1.1.1",
"version": "16.0.1.1.2",
"license": "AGPL-3",
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
Expand Down
21 changes: 18 additions & 3 deletions report_substitute/models/ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,28 @@ def _render(self, report_ref, res_ids, data=None):
substitution_report.report_name, res_ids, data=data
)

def _render_qweb_pdf(self, report_ref, res_ids=None, data=None):
report = self._get_report(report_ref)
substitution_report = report.get_substitution_report(res_ids)
def _render_qweb_pdf_substitution(
self, substitution_report, res_ids=None, data=None
):
"""Hook to render substitution reports with another report_type.

Return a ``(content, report_type)`` tuple, or ``None`` to fall
back to rendering the original report.
"""
if substitution_report.filtered(lambda r: r.report_type == "qweb-pdf"):
return super(IrActionReport, self)._render_qweb_pdf(
substitution_report, res_ids=res_ids, data=data
)
return None

def _render_qweb_pdf(self, report_ref, res_ids=None, data=None):
report = self._get_report(report_ref)
substitution_report = report.get_substitution_report(res_ids)
result = self._render_qweb_pdf_substitution(
substitution_report, res_ids=res_ids, data=data
)
if result is not None:
return result
return super(IrActionReport, self)._render_qweb_pdf(
report_ref, res_ids=res_ids, data=data
)
Expand Down
2 changes: 1 addition & 1 deletion report_substitute/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Report Substitute</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6e713ec7c433154ddfbdc2a954a61a5df2fcdabf03d875d3b3dd5bd0ce4ff980
!! source digest: sha256:308f4cd2414839b00119166f359a14cc6430df7ee469e2069829e683b8a464c6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/16.0/report_substitute"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-report_substitute"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to create substitution rules for report actions.
Expand Down
11 changes: 11 additions & 0 deletions report_substitute/tests/test_report_substitute.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,14 @@ def test_substitution_infinite_loop(self):
).id,
}
)

def test_render_qweb_pdf_falls_back_for_non_qweb_substitute(self):
# A substitute whose report_type is not qweb-pdf cannot be rendered
# by _render_qweb_pdf, which should fall back to the original report.
self.substitution_rule.substitution_action_report_id.report_type = "qweb-text"
res = str(
self.action_report._render_qweb_pdf(
self.action_report.report_name, res_ids=self.res_ids
)[0]
)
self.assertNotIn('<div class="page">Substitution Report</div>', res)