diff --git a/report_substitute/models/ir_actions_report.py b/report_substitute/models/ir_actions_report.py index e8c45b43..a987b24f 100644 --- a/report_substitute/models/ir_actions_report.py +++ b/report_substitute/models/ir_actions_report.py @@ -41,17 +41,17 @@ class IrActionReport(models.Model): return action_report @api.model - def get_substitution_report_dict(self, action_report_dict, active_ids): - if action_report_dict.get('id'): - action_report = self.browse(action_report_dict['id']) + def get_substitution_report_action(self, action, active_ids): + if action.get('id'): + action_report = self.browse(action['id']) substitution_report = action_report while substitution_report: action_report = substitution_report substitution_report = action_report._get_substitution_report( action_report.model, active_ids ) - action_report_dict.update(action_report.read()[0]) - return action_report_dict + action.update(action_report.read()[0]) + return action @api.multi def render(self, res_ids, data=None): diff --git a/report_substitute/static/src/js/action_manager.js b/report_substitute/static/src/js/action_manager.js index 3f7bc14f..6e4e8f8d 100644 --- a/report_substitute/static/src/js/action_manager.js +++ b/report_substitute/static/src/js/action_manager.js @@ -14,17 +14,19 @@ odoo.define("report_substitute.action_report_substitute", function (require) { _handleAction: function (action, options) { if (action.type === "ir.actions.report" && - action.context.active_ids) { + action.context.active_ids && + action.action_report_substitution_rule_ids && + action.action_report_substitution_rule_ids != 0) { var active_ids = action.context.active_ids; var self = this; var _super = this._super; var callersArguments = arguments; return this._rpc({ model: "ir.actions.report", - method: "get_substitution_report_dict", + method: "get_substitution_report_action", args: [action, active_ids] - }).then(function (action_id) { - callersArguments[0] = action_id + }).then(function (substitution_action) { + callersArguments[0] = substitution_action return _super.apply(self, callersArguments); }); @@ -34,4 +36,4 @@ odoo.define("report_substitute.action_report_substitute", function (require) { }); -}); +}); \ No newline at end of file diff --git a/report_substitute/tests/test_report_substitute.py b/report_substitute/tests/test_report_substitute.py index fecb4be6..75065bd0 100644 --- a/report_substitute/tests/test_report_substitute.py +++ b/report_substitute/tests/test_report_substitute.py @@ -46,3 +46,21 @@ class TestReportSubstitute(TransactionCase): self.substitution_rule.write({'domain': "[('name', '!=', 'base')]"}) res = str(self.action_report.render(res_ids=self.res_ids)[0]) self.assertNotIn('