mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[MIG] report_substitute: Migration to 17.0
This commit is contained in:
BIN
pandoc-3.1.12.1-1-amd64.deb
Normal file
BIN
pandoc-3.1.12.1-1-amd64.deb
Normal file
Binary file not shown.
@@ -1,2 +1 @@
|
||||
from . import models
|
||||
from . import wizards
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
from . import mail_compose_message
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user