Skip to content

Commit

Permalink
[15.0][MIG] report_substitute
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Sep 6, 2024
1 parent 2ba6ea6 commit 6565b3a
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 59 deletions.
10 changes: 5 additions & 5 deletions report_substitute/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Report Substitute
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/16.0/report_substitute
:target: https://github.com/OCA/reporting-engine/tree/15.0/report_substitute
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-report_substitute
:target: https://translation.odoo-community.org/projects/reporting-engine-15-0/reporting-engine-15-0-report_substitute
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -68,7 +68,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_substitute%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_substitute%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -106,6 +106,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sbejaoui|

This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/16.0/report_substitute>`_ project on GitHub.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/15.0/report_substitute>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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.0.2",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
Expand Down
16 changes: 14 additions & 2 deletions report_substitute/demo/action_report.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="substitution_report">
<div class="page">Substitution Report</div>
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.internal_layout">
<div class="page">Substitution Report</div>
</t>
</t>
</t>
</template>
<record id="substitution_report_print" model="ir.actions.report">
<field name="name">Substitution For Technical guide</field>
Expand All @@ -19,7 +25,13 @@
/>
</record>
<template id="substitution_report_2">
<div class="page">Substitution Report 2</div>
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.internal_layout">
<div class="page">Substitution Report 2</div>
</t>
</t>
</t>
</template>
<record id="substitution_report_print_2" model="ir.actions.report">
<field name="name">Substitution 2 For Technical guide</field>
Expand Down
18 changes: 7 additions & 11 deletions report_substitute/models/ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ def get_substitution_report_action(self, action, active_ids):

return action

def _render(self, report_ref, res_ids, data=None):
report = self._get_report(report_ref)
substitution_report = report.get_substitution_report(res_ids)
return super(IrActionReport, self)._render(
substitution_report.report_name, res_ids, data=data
)
def _render(self, res_ids, data=None):
substitution_report = self.get_substitution_report(res_ids)
return super(IrActionReport, substitution_report)._render(res_ids, 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)
return super(IrActionReport, self)._render_qweb_pdf(
substitution_report, res_ids=res_ids, data=data
def _render_qweb_pdf(self, res_ids=None, data=None):
substitution_report = self.get_substitution_report(res_ids)
return super(IrActionReport, substitution_report)._render_qweb_pdf(
res_ids=res_ids, data=data
)

def report_action(self, docids, data=None, config=True):
Expand Down
17 changes: 7 additions & 10 deletions report_substitute/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,7 +368,7 @@ <h1 class="title">Report Substitute</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c8dc45c73e2d23ef5504e4ffbae69fe4c62e4e64f8a8b6ef11b13adbb7a7ebb6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/licence-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><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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/15.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-15-0/reporting-engine-15-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=15.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.
A typical use case is to replace a standard report by alternative reports
when some conditions are met. For instance, it allows to configure alternate
Expand Down Expand Up @@ -412,7 +411,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_substitute%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_substitute%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -432,15 +431,13 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/sbejaoui"><img alt="sbejaoui" src="https://github.com/sbejaoui.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/16.0/report_substitute">OCA/reporting-engine</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/15.0/report_substitute">OCA/reporting-engine</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
36 changes: 6 additions & 30 deletions report_substitute/tests/test_report_substitute.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,15 @@ def setUp(self):
).id

def test_substitution(self):
res = str(
self.action_report._render(
self.action_report.report_name, res_ids=self.res_ids
)[0]
)
res = str(self.action_report._render(res_ids=self.res_ids)[0])
self.assertIn('<div class="page">Substitution Report</div>', res)
# remove the substation rule
self.substitution_rule.unlink()
res = str(
self.action_report._render(
self.action_report.report_name, res_ids=self.res_ids
)[0]
)
res = str(self.action_report._render(res_ids=self.res_ids)[0])
self.assertNotIn('<div class="page">Substitution Report</div>', res)

def test_recursive_substitution(self):
res = str(
self.action_report._render(
self.action_report.report_name, res_ids=self.res_ids
)[0]
)
res = str(self.action_report._render(res_ids=self.res_ids)[0])
self.assertNotIn('<div class="page">Substitution Report 2</div>', res)
self.env["ir.actions.report.substitution.rule"].create(
{
Expand All @@ -52,27 +40,15 @@ def test_recursive_substitution(self):
).id,
}
)
res = str(
self.action_report._render(
self.action_report.report_name, res_ids=self.res_ids
)[0]
)
res = str(self.action_report._render(res_ids=self.res_ids)[0])
self.assertIn('<div class="page">Substitution Report 2</div>', res)

def test_substitution_with_domain(self):
self.substitution_rule.write({"domain": "[('name', '=', 'base')]"})
res = str(
self.action_report._render(
self.action_report.report_name, res_ids=self.res_ids
)[0]
)
res = str(self.action_report._render(res_ids=self.res_ids)[0])
self.assertIn('<div class="page">Substitution Report</div>', res)
self.substitution_rule.write({"domain": "[('name', '!=', 'base')]"})
res = str(
self.action_report._render(
self.action_report.report_name, res_ids=self.res_ids
)[0]
)
res = str(self.action_report._render(res_ids=self.res_ids)[0])
self.assertNotIn('<div class="page">Substitution Report</div>', res)

def test_substitution_with_action_dict(self):
Expand Down
1 change: 1 addition & 0 deletions setup/report_substitute/odoo/addons/report_substitute
6 changes: 6 additions & 0 deletions setup/report_substitute/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 6565b3a

Please sign in to comment.