[IMP] - manage subtitute report for multi-action
parent
9c7d245343
commit
6f831d7f48
|
@ -14,6 +14,7 @@
|
||||||
'depends': ['base'],
|
'depends': ['base'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir_actions_report_substitution_rule.xml',
|
'security/ir_actions_report_substitution_rule.xml',
|
||||||
|
'views/assets_backend.xml',
|
||||||
'views/ir_actions_report.xml',
|
'views/ir_actions_report.xml',
|
||||||
],
|
],
|
||||||
'demo': ['demo/action_report.xml'],
|
'demo': ['demo/action_report.xml'],
|
||||||
|
|
|
@ -25,11 +25,22 @@ class IrActionReport(models.Model):
|
||||||
domain = safe_eval(substitution_report_rule.domain)
|
domain = safe_eval(substitution_report_rule.domain)
|
||||||
domain.append(('id', 'in', active_ids))
|
domain.append(('id', 'in', active_ids))
|
||||||
if set(model.search(domain).ids) == set(active_ids):
|
if set(model.search(domain).ids) == set(active_ids):
|
||||||
return (
|
return substitution_report_rule.substitution_action_report_id
|
||||||
substitution_report_rule.substitution_action_report_id
|
|
||||||
)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@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'])
|
||||||
|
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
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def render(self, res_ids, data=None):
|
def render(self, res_ids, data=None):
|
||||||
substitution_report = self._get_substitution_report(
|
substitution_report = self._get_substitution_report(
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2019 ACSONE SA/NV
|
||||||
|
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
odoo.define('report_substitute.action_report_substitute', function(require) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var ActionManager = require('web.ActionManager');
|
||||||
|
|
||||||
|
ActionManager.include({
|
||||||
|
/**
|
||||||
|
* Intercept action handling substitute the report action
|
||||||
|
* @override
|
||||||
|
*/
|
||||||
|
_handleAction: function(action, options) {
|
||||||
|
if (action.type === 'ir.actions.report' &&
|
||||||
|
action.context.active_ids) {
|
||||||
|
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',
|
||||||
|
args: [action, active_ids]
|
||||||
|
}).then(function(action_id) {
|
||||||
|
callersArguments[0] = action_id
|
||||||
|
return _super.apply(self, callersArguments);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
return this._super.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<template id="assets_backend" name="report assets" inherit_id="web.assets_backend">
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<script type="text/javascript" src="/report_substitute/static/src/js/action_manager.js"></script>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue