Skip to content

Commit 410659a

Browse files
committed
[MIG] report_substitute: Migration to 17.0
1 parent 2055777 commit 410659a

10 files changed

+29
-56
lines changed

pandoc-3.1.12.1-1-amd64.deb

30 MB
Binary file not shown.

report_substitute/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from . import models
2-
from . import wizards

report_substitute/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"summary": """
77
This module allows to create substitution rules for report actions.
88
""",
9-
"version": "16.0.1.0.1",
9+
"version": "17.0.1.0.0",
1010
"license": "AGPL-3",
1111
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
1212
"website": "https://github.com/OCA/reporting-engine",

report_substitute/models/ir_actions_report.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,19 @@ def get_substitution_report_action(self, action, active_ids):
4545
substitution_report = action_report._get_substitution_report(
4646
action_report.model, active_ids
4747
)
48-
action.update(action_report.read()[0])
48+
action.update(self._for_xml_id(action_report.xml_id))
4949

5050
return action
5151

5252
def _render(self, report_ref, res_ids, data=None):
5353
report = self._get_report(report_ref)
5454
substitution_report = report.get_substitution_report(res_ids)
55-
return super(IrActionReport, self)._render(
56-
substitution_report.report_name, res_ids, data=data
57-
)
55+
return super()._render(substitution_report.report_name, res_ids, data=data)
5856

5957
def _render_qweb_pdf(self, report_ref, res_ids=None, data=None):
6058
report = self._get_report(report_ref)
6159
substitution_report = report.get_substitution_report(res_ids)
62-
return super(IrActionReport, self)._render_qweb_pdf(
63-
substitution_report, res_ids=res_ids, data=data
64-
)
60+
return super()._render_qweb_pdf(substitution_report, res_ids=res_ids, data=data)
6561

6662
def report_action(self, docids, data=None, config=True):
6763
if docids:

report_substitute/models/mail_thread.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,27 @@
77
class MailThread(models.AbstractModel):
88
_inherit = "mail.thread"
99

10-
def message_post_with_template(self, template_id, **kwargs):
11-
template = self.env["mail.template"].browse(template_id)
12-
old_report = False
13-
if template and template.report_template and self.ids:
14-
active_ids = self.ids
15-
old_report = template.report_template
16-
template.report_template = old_report.get_substitution_report(active_ids)
17-
res = super().message_post_with_template(template_id, **kwargs)
18-
if old_report:
19-
template.report_template = old_report
10+
def message_post_with_source(
11+
self,
12+
source_ref,
13+
render_values=None,
14+
message_type="notification",
15+
subtype_xmlid=False,
16+
subtype_id=False,
17+
**kwargs,
18+
):
19+
template, view = self._get_source_from_ref(source_ref)
20+
old_report_template_ids = False
21+
if template and template.report_template_ids and self.ids:
22+
old_report_template_ids = template.report_template_ids
23+
new_report_template_ids = [
24+
report.get_substitution_report(self.ids).id
25+
for report in template.report_template_ids
26+
]
27+
template.update({"report_template_ids": [(6, 0, new_report_template_ids)]})
28+
res = super().message_post_with_source(
29+
source_ref, render_values, message_type, subtype_xmlid, subtype_id, **kwargs
30+
)
31+
if old_report_template_ids:
32+
template.report_template_ids = old_report_template_ids
2033
return res

report_substitute/static/description/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>

report_substitute/static/src/js/action_manager.esm.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {registry} from "@web/core/registry";
44

55
registry
66
.category("ir.actions.report handlers")
7-
.add("sustitution_handler", async function (action, options, env) {
7+
.add("substitution_handler", async function (action, options, env) {
88
const orm = env.services.orm;
99
const action_report_substitution_rule_ids = await orm.call(
1010
"ir.actions.report",

report_substitute/tests/test_report_substitute.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TestReportSubstitute(TransactionCase):
99
def setUp(self):
1010
# In the demo file we create a new report for ir.module.module model
1111
# with a substation rule from the original report action
12-
super(TestReportSubstitute, self).setUp()
12+
super().setUp()
1313
self.action_report = self.env.ref("base.ir_module_reference_print")
1414
self.res_ids = self.env.ref("base.module_base").ids
1515
self.substitution_rule = self.env.ref(

report_substitute/wizards/__init__.py

-1
This file was deleted.

report_substitute/wizards/mail_compose_message.py

-33
This file was deleted.

0 commit comments

Comments
 (0)