Skip to content

Commit 29a842b

Browse files
sakthi-shanlef-adhoc
authored andcommitted
[MIG] report_substitute-V17
1 parent 68ae4da commit 29a842b

File tree

7 files changed

+25
-47
lines changed

7 files changed

+25
-47
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/models/ir_actions_report.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ 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

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.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/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/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)