Skip to content

Commit

Permalink
[MIG] report_substitute: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasperalta1 committed Sep 13, 2022
1 parent c0d04af commit 41c9008
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 56 deletions.
8 changes: 6 additions & 2 deletions report_substitute/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@
"summary": """
This module allows to create substitution rules for report actions.
""",
"version": "13.0.1.0.0",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"depends": ["base", "mail"],
"data": [
"security/ir_actions_report_substitution_rule.xml",
"views/assets_backend.xml",
"views/ir_actions_report.xml",
],
"demo": ["demo/action_report.xml"],
"assets": {
"web.assets_backend": [
"report_substitute/static/src/js/action_manager.esm.js",
],
},
"maintainers": ["sbejaoui"],
}
12 changes: 8 additions & 4 deletions report_substitute/models/ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class IrActionReport(models.Model):
_inherit = "ir.actions.report"

action_report_substitution_rule_ids = fields.One2many(
comodel_name="ir.actions.report.substitution.rule",
inverse_name="action_report_id",
"ir.actions.report.substitution.rule",
"action_report_id",
string="Substitution Rules",
)

Expand Down Expand Up @@ -47,11 +47,12 @@ def get_substitution_report_action(self, action, active_ids):
action_report.model, active_ids
)
action.update(action_report.read()[0])

return action

def render(self, res_ids, data=None):
def _render(self, res_ids, data=None):
substitution_report = self.get_substitution_report(res_ids)
return super(IrActionReport, substitution_report).render(res_ids, data)
return super(IrActionReport, substitution_report)._render(res_ids, data)

def report_action(self, docids, data=None, config=True):
if docids:
Expand All @@ -66,3 +67,6 @@ def report_action(self, docids, data=None, config=True):
docids, data, config
)
return super().report_action(docids, data, config)

def get_action_report_substitution_rule_ids(self):
return self.action_report_substitution_rule_ids.ids
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ActionsReportSubstitutionRule(models.Model):
ondelete="cascade",
)
model = fields.Char(related="action_report_id.model", store=True)
domain = fields.Char(string="Domain", required=True, default="[]")
domain = fields.Char(required=True, default="[]")
substitution_action_report_id = fields.Many2one(
comodel_name="ir.actions.report",
string="Substitution Report Action",
Expand All @@ -37,7 +37,8 @@ def _check_infinite_loop(original_report, substitution_report):
substitution_rule
) in substitution_report.action_report_substitution_rule_ids:
_check_infinite_loop(
original_report, substitution_rule.substitution_action_report_id,
original_report,
substitution_rule.substitution_action_report_id,
)

for rec in self:
Expand Down
29 changes: 29 additions & 0 deletions report_substitute/static/src/js/action_manager.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/** @odoo-module **/

import {registry} from "@web/core/registry";

registry
.category("ir.actions.report handlers")
.add("sustitution_handler", async function (action, options, env) {
const orm = env.services.orm;
const action_report_substitution_rule_ids = await orm.call(
"ir.actions.report",
"get_action_report_substitution_rule_ids",
[action.id]
);
if (
action.type === "ir.actions.report" &&
action.context.active_ids &&
action_report_substitution_rule_ids &&
action_report_substitution_rule_ids.length !== 0
) {
var active_ids = action.context.active_ids;
const substitution = await orm.call(
"ir.actions.report",
"get_substitution_report_action",
[action, active_ids]
);
Object.assign(action, substitution);
}
return Promise.resolve(false);
});
35 changes: 0 additions & 35 deletions report_substitute/static/src/js/action_manager.js

This file was deleted.

11 changes: 0 additions & 11 deletions report_substitute/views/assets_backend.xml

This file was deleted.

4 changes: 2 additions & 2 deletions report_substitute/wizards/mail_compose_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def onchange_template_id_wrapper(self):
active_ids
)
onchange_result_with_substituted_report = (
super().onchange_template_id_wrapper()
super()._onchange_template_id_wrapper()
)
self.template_id.report_template = old_tmpl
return onchange_result_with_substituted_report
return super().onchange_template_id_wrapper()
return super()._onchange_template_id_wrapper()

0 comments on commit 41c9008

Please sign in to comment.