summaryrefslogtreecommitdiff
path: root/addons/report/static
diff options
context:
space:
mode:
authorMartin Geubelle <mge@odoo.com>2016-09-14 10:52:11 +0200
committerGéry Debongnie <ged@odoo.com>2016-09-28 16:55:51 +0200
commitfa4fa908900b01ca6a2bcde61b73ec6e45d936d2 (patch)
tree81680234c79a71c474469366aa1e100b7df5a492 /addons/report/static
parentb782a5d922faf5667ce4b3f53c515553f2ca9dd8 (diff)
[REF] report: allow client action to be extended
The iframe is set in a template inside a div. The widget is returned so it can be extended.
Diffstat (limited to 'addons/report/static')
-rw-r--r--addons/report/static/src/js/client_action.js22
-rw-r--r--addons/report/static/src/xml/report.xml6
2 files changed, 18 insertions, 10 deletions
diff --git a/addons/report/static/src/js/client_action.js b/addons/report/static/src/js/client_action.js
index c940f03150b..041a7af383b 100644
--- a/addons/report/static/src/js/client_action.js
+++ b/addons/report/static/src/js/client_action.js
@@ -18,8 +18,7 @@ var AUTHORIZED_MESSAGES = [
var ReportAction = Widget.extend(ControlPanelMixin, {
- tagName: 'iframe',
- className: 'o_report_iframe',
+ template: 'report.client_action',
init: function (parent, action, options) {
this._super.apply(this, arguments);
@@ -43,6 +42,7 @@ var ReportAction = Widget.extend(ControlPanelMixin, {
start: function () {
var self = this;
this.set('title', this.title);
+ this.iframe = this.$('iframe')[0];
return $.when(this._super.apply(this, arguments), session.is_bound).then(function () {
var web_base_url = session['web.base.url'];
var trusted_host = utils.get_host_from_url(web_base_url);
@@ -58,10 +58,10 @@ var ReportAction = Widget.extend(ControlPanelMixin, {
self._update_control_panel();
// Load the report in the iframe. Note that we use a relative URL.
- self.el.src = self.report_url;
+ self.iframe.src = self.report_url;
// Once the iframe is loaded, check if we can edit the report.
- self.el.onload = function () {
+ self.iframe.onload = function () {
self._on_iframe_loaded();
};
});
@@ -84,7 +84,7 @@ var ReportAction = Widget.extend(ControlPanelMixin, {
},
_on_iframe_loaded: function () {
- var editable = this.$el.contents().find('html').data('editable');
+ var editable = $(this.iframe).contents().find('html').data('editable');
if (editable === 1) {
this.edit_mode_available = true;
this._update_control_panel();
@@ -132,13 +132,13 @@ var ReportAction = Widget.extend(ControlPanelMixin, {
switch(message) {
case 'report.editor:save_ok':
// Reload the iframe in order to disable the editor.
- this.el.src = this.report_url;
+ this.iframe.src = this.report_url;
this.in_edit_mode = false;
this._update_control_panel_buttons();
break;
case 'report.editor:discard_ok':
// Reload the iframe in order to disable the editor.
- this.el.src = this.report_url;
+ this.iframe.src = this.report_url;
this.in_edit_mode = false;
this._update_control_panel_buttons();
break;
@@ -156,15 +156,15 @@ var ReportAction = Widget.extend(ControlPanelMixin, {
* this method we only send the message to a trusted domain.
*/
_post_message: function (message) {
- this.el.contentWindow.postMessage(message, this.trusted_origin);
+ this.iframe.contentWindow.postMessage(message, this.trusted_origin);
},
on_click_edit: function () {
// We reload the iframe with a special query string to enable the editor.
if (this.report_url.indexOf('?') === -1) {
- this.el.src = this.report_url + '?enable_editor=1';
+ this.iframe.src = this.report_url + '?enable_editor=1';
} else {
- this.el.src = this.report_url + '&enable_editor=1';
+ this.iframe.src = this.report_url + '&enable_editor=1';
}
this.in_edit_mode = true;
this._update_control_panel_buttons();
@@ -195,4 +195,6 @@ var ReportAction = Widget.extend(ControlPanelMixin, {
core.action_registry.add('report.client_action', ReportAction);
+return ReportAction;
+
});
diff --git a/addons/report/static/src/xml/report.xml b/addons/report/static/src/xml/report.xml
index 741022259d0..c578add8ce9 100644
--- a/addons/report/static/src/xml/report.xml
+++ b/addons/report/static/src/xml/report.xml
@@ -1,4 +1,10 @@
<template>
+
+ <!-- Main layout (iframe) -->
+ <div t-name="report.client_action">
+ <iframe class="o_report_iframe"/>
+ </div>
+
<!-- Buttons of the Control Panel -->
<t t-name="report.client_action.ControlButtons">
<div class="o_report_no_edit_mode">