summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2016-06-28 12:05:51 +0200
committerSimon Lejeune <sle@openerp.com>2016-07-05 17:44:56 +0200
commitb7de723b8c737b8d66f53cdde6d714eef31e2d1d (patch)
treed1d2db99fb7802ac17b18cb58939a1ed40e8912e /addons
parent752cd0a482d1302131003b3066b3031356ddbf30 (diff)
[ADD] report: improve client action to allow sending `do_action` commands
Diffstat (limited to 'addons')
-rw-r--r--addons/report/static/src/js/client_action.js6
-rw-r--r--addons/report/static/src/js/report.editor.js23
2 files changed, 29 insertions, 0 deletions
diff --git a/addons/report/static/src/js/client_action.js b/addons/report/static/src/js/client_action.js
index 22d53d57eea..4538b9df11b 100644
--- a/addons/report/static/src/js/client_action.js
+++ b/addons/report/static/src/js/client_action.js
@@ -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:
}
}
diff --git a/addons/report/static/src/js/report.editor.js b/addons/report/static/src/js/report.editor.js
index 21c8500b6ed..5b58793bbf5 100644
--- a/addons/report/static/src/js/report.editor.js
+++ b/addons/report/static/src/js/report.editor.js
@@ -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({