diff --git a/pandoc-3.1.12.1-1-amd64.deb b/pandoc-3.1.12.1-1-amd64.deb new file mode 100644 index 000000000..d8e51d6c3 Binary files /dev/null and b/pandoc-3.1.12.1-1-amd64.deb differ diff --git a/report_substitute/__init__.py b/report_substitute/__init__.py index aee8895e7..0650744f6 100644 --- a/report_substitute/__init__.py +++ b/report_substitute/__init__.py @@ -1,2 +1 @@ from . import models -from . import wizards diff --git a/report_substitute/__manifest__.py b/report_substitute/__manifest__.py index f70991041..cf3a2a90d 100644 --- a/report_substitute/__manifest__.py +++ b/report_substitute/__manifest__.py @@ -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", diff --git a/report_substitute/models/ir_actions_report.py b/report_substitute/models/ir_actions_report.py index ecd1e368b..cb7896443 100644 --- a/report_substitute/models/ir_actions_report.py +++ b/report_substitute/models/ir_actions_report.py @@ -45,23 +45,19 @@ class IrActionReport(models.Model): 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: diff --git a/report_substitute/models/mail_thread.py b/report_substitute/models/mail_thread.py index c00d466aa..d9c83f786 100644 --- a/report_substitute/models/mail_thread.py +++ b/report_substitute/models/mail_thread.py @@ -7,14 +7,27 @@ from odoo import models 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 and 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 diff --git a/report_substitute/static/description/index.html b/report_substitute/static/description/index.html index f52391c7a..40502205f 100644 --- a/report_substitute/static/description/index.html +++ b/report_substitute/static/description/index.html @@ -1,4 +1,3 @@ - diff --git a/report_substitute/static/src/js/action_manager.esm.js b/report_substitute/static/src/js/action_manager.esm.js index cff852c70..1fe7774bd 100644 --- a/report_substitute/static/src/js/action_manager.esm.js +++ b/report_substitute/static/src/js/action_manager.esm.js @@ -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", diff --git a/report_substitute/tests/test_report_substitute.py b/report_substitute/tests/test_report_substitute.py index 88796624d..6772b976c 100644 --- a/report_substitute/tests/test_report_substitute.py +++ b/report_substitute/tests/test_report_substitute.py @@ -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( diff --git a/report_substitute/wizards/__init__.py b/report_substitute/wizards/__init__.py deleted file mode 100644 index b528d997d..000000000 --- a/report_substitute/wizards/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import mail_compose_message diff --git a/report_substitute/wizards/mail_compose_message.py b/report_substitute/wizards/mail_compose_message.py deleted file mode 100644 index b71ca8175..000000000 --- a/report_substitute/wizards/mail_compose_message.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2019 ACSONE SA/NV -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import api, models - - -class MailComposeMessage(models.TransientModel): - _inherit = "mail.compose.message" - - @api.onchange("template_id") - def onchange_template_id_wrapper(self): - if self.template_id: - report_template = self.template_id.report_template - active_ids = [] - if self.env.context.get("active_ids"): - active_ids = self.env.context.get("active_ids") - elif self.env.context.get("default_res_id"): - active_ids = [self.env.context.get("default_res_id")] - if ( - report_template - and report_template.action_report_substitution_rule_ids - and active_ids - ): - old_tmpl = report_template - self.template_id.report_template = old_tmpl.get_substitution_report( - active_ids - ) - onchange_result_with_substituted_report = ( - super()._onchange_template_id_wrapper() - ) - self.template_id.report_template = old_tmpl - return onchange_result_with_substituted_report - return super()._onchange_template_id_wrapper()