summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/report/report.editor.js24
-rw-r--r--addons/web/static/src/js/report/report.js40
2 files changed, 40 insertions, 24 deletions
diff --git a/addons/web/static/src/js/report/report.editor.js b/addons/web/static/src/js/report/report.editor.js
index 15da9885e31..4955417a759 100644
--- a/addons/web/static/src/js/report/report.editor.js
+++ b/addons/web/static/src/js/report/report.editor.js
@@ -14,7 +14,6 @@ var trusted_origin = utils.build_origin(trusted_protocol, trusted_host);
// Patch the editor's behavior when it is launched inside an iframe.
if (window.self !== window.top) {
- $(document.body).addClass('o_in_iframe'); // in order to apply css rules
// And now we chain some deferred to `save` and `cancel` in order to inform
// the report's client action that the actions are done.
@@ -60,29 +59,6 @@ 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({
diff --git a/addons/web/static/src/js/report/report.js b/addons/web/static/src/js/report/report.js
new file mode 100644
index 00000000000..50d78a9d151
--- /dev/null
+++ b/addons/web/static/src/js/report/report.js
@@ -0,0 +1,40 @@
+odoo.define('report', function (require) {
+'use strict';
+
+require('web.dom_ready');
+var utils = require('report.utils');
+
+if (window.self === window.top) {
+ return;
+}
+
+$(document.body).addClass('o_in_iframe'); // in order to apply css rules
+
+var web_base_url = $('html').attr('web-base-url');
+var trusted_host = utils.get_host_from_url(web_base_url);
+var trusted_protocol = utils.get_protocol_from_url(web_base_url);
+var trusted_origin = utils.build_origin(trusted_protocol, trusted_host);
+
+// 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);
+ });
+}
+});