[ADD] report: improve client action to allow sending do_action commands
This commit is contained in:
@@ -13,6 +13,7 @@ var QWeb = core.qweb;
|
||||
var AUTHORIZED_MESSAGES = [
|
||||
'report.editor:save_ok',
|
||||
'report.editor:discard_ok',
|
||||
'report:do_action',
|
||||
];
|
||||
|
||||
var ReportAction = Widget.extend(ControlPanelMixin, {
|
||||
@@ -124,6 +125,9 @@ var ReportAction = Widget.extend(ControlPanelMixin, {
|
||||
|
||||
// Check the syntax of the received message.
|
||||
var message = ev.originalEvent.data;
|
||||
if (_.isObject(message)) {
|
||||
message = message.message;
|
||||
}
|
||||
if (! _.isString(message) || (_.isString(message) && ! _.contains(AUTHORIZED_MESSAGES, message))) {
|
||||
return;
|
||||
}
|
||||
@@ -141,6 +145,8 @@ var ReportAction = Widget.extend(ControlPanelMixin, {
|
||||
this.in_edit_mode = false;
|
||||
this._update_control_panel_buttons();
|
||||
break;
|
||||
case 'report:do_action':
|
||||
return this.do_action(ev.originalEvent.data.action);
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,29 @@ if (window.self !== window.top) {
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
// Allow to send commands to the webclient when the editor is disabled.
|
||||
if (window.location.search.indexOf('enable_editor') === -1) {
|
||||
// `do_action` command
|
||||
$('[res-id][res-model][view-type]')
|
||||
.wrap('<a/>')
|
||||
.attr('href', '#')
|
||||
.on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
var action = {
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': $(this).attr('view-type'),
|
||||
'view_mode': $(this).attr('view-mode') || $(this).attr('view-type'),
|
||||
'res_id': Number($(this).attr('res-id')),
|
||||
'res_model': $(this).attr('res-model'),
|
||||
'views': [[$(this).attr('view-id') || false, $(this).attr('view-type')]],
|
||||
};
|
||||
window.parent.postMessage({
|
||||
'message': 'report:do_action',
|
||||
'action': action,
|
||||
}, trusted_origin);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
options.registry.many2one.include({
|
||||
|
||||
Reference in New Issue
Block a user