diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/web/static/src/js/report/report.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/web/static/src/js/report/report.js')
| -rw-r--r-- | addons/web/static/src/js/report/report.js | 42 |
1 files changed, 42 insertions, 0 deletions
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 00000000..daf50c0e --- /dev/null +++ b/addons/web/static/src/js/report/report.js @@ -0,0 +1,42 @@ +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') + .addClass('container-fluid') + .removeClass('container'); + +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 sending commands to the webclient +// `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_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); + }); +}); |
