Skip to content

Commit

Permalink
[MIG] report_substitute: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lef-adhoc committed Apr 15, 2024
1 parent 2055777 commit 633f9ba
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 55 deletions.
Binary file added pandoc-3.1.12.1-1-amd64.deb
Binary file not shown.
1 change: 0 additions & 1 deletion report_substitute/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import models
from . import wizards
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.1",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
Expand Down
10 changes: 3 additions & 7 deletions report_substitute/models/ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,19 @@ def get_substitution_report_action(self, action, active_ids):
substitution_report = action_report._get_substitution_report(
action_report.model, active_ids
)
action.update(action_report.read()[0])
action.update(self._for_xml_id(action_report.xml_id))

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
)
return super()._render(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)
return super(IrActionReport, self)._render_qweb_pdf(
substitution_report, res_ids=res_ids, data=data
)
return super()._render_qweb_pdf(substitution_report, res_ids=res_ids, data=data)

def report_action(self, docids, data=None, config=True):
if docids:
Expand Down
33 changes: 23 additions & 10 deletions report_substitute/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,27 @@
class MailThread(models.AbstractModel):
_inherit = "mail.thread"

def message_post_with_template(self, template_id, **kwargs):
template = self.env["mail.template"].browse(template_id)
old_report = False
if template and template.report_template and self.ids:
active_ids = self.ids
old_report = template.report_template
template.report_template = old_report.get_substitution_report(active_ids)
res = super().message_post_with_template(template_id, **kwargs)
if old_report:
template.report_template = old_report
def message_post_with_source(
self,
source_ref,
render_values=None,
message_type="notification",
subtype_xmlid=False,
subtype_id=False,
**kwargs,
):
template, view = self._get_source_from_ref(source_ref)
old_report_template_ids = False
if template.report_template_ids and self.ids:
old_report_template_ids = template.report_template_ids
new_report_template_ids = [
report.get_substitution_report(self.ids).id
for report in template.report_template_ids
]
template.update({"report_template_ids": [(6, 0, new_report_template_ids)]})
res = super().message_post_with_source(
source_ref, render_values, message_type, subtype_xmlid, subtype_id, **kwargs
)
if old_report_template_ids:
template.report_template_ids = old_report_template_ids
return res
2 changes: 1 addition & 1 deletion report_substitute/static/src/js/action_manager.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {registry} from "@web/core/registry";

registry
.category("ir.actions.report handlers")
.add("sustitution_handler", async function (action, options, env) {
.add("substitution_handler", async function (action, options, env) {
const orm = env.services.orm;
const action_report_substitution_rule_ids = await orm.call(
"ir.actions.report",
Expand Down
2 changes: 1 addition & 1 deletion report_substitute/tests/test_report_substitute.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TestReportSubstitute(TransactionCase):
def setUp(self):
# In the demo file we create a new report for ir.module.module model
# with a substation rule from the original report action
super(TestReportSubstitute, self).setUp()
super().setUp()
self.action_report = self.env.ref("base.ir_module_reference_print")
self.res_ids = self.env.ref("base.module_base").ids
self.substitution_rule = self.env.ref(
Expand Down
1 change: 0 additions & 1 deletion report_substitute/wizards/__init__.py

This file was deleted.

33 changes: 0 additions & 33 deletions report_substitute/wizards/mail_compose_message.py

This file was deleted.

0 comments on commit 633f9ba

Please sign in to comment.