Browse Source

pre-commit update

14.0
OCA-git-bot 5 years ago
committed by Alex Cuellar
parent
commit
da836c1ca3
  1. 51
      report_xlsx/static/src/js/report/action_manager_report.js
  2. 6
      report_xlsx/views/webclient_templates.xml

51
report_xlsx/static/src/js/report/action_manager_report.js

@ -10,7 +10,6 @@ odoo.define("report_xlsx.report", function (require) {
var _t = core._t;
ActionManager.include({
_downloadReportXLSX: function(url, actions) {
var self = this;
framework.blockUI();
@ -18,17 +17,21 @@ odoo.define("report_xlsx.report", function (require) {
var cloned_action = _.clone(actions);
var new_url = url;
if (_.isUndefined(cloned_action.data) ||
if (
_.isUndefined(cloned_action.data) ||
_.isNull(cloned_action.data) ||
(_.isObject(cloned_action.data) && _.isEmpty(cloned_action.data))) {
(_.isObject(cloned_action.data) && _.isEmpty(cloned_action.data))
) {
if (cloned_action.context.active_ids) {
new_url += "/" + cloned_action.context.active_ids.join(',');
new_url += "/" + cloned_action.context.active_ids.join(",");
}
} else {
new_url += "?options=" + encodeURIComponent(
JSON.stringify(cloned_action.data));
new_url += "&context=" + encodeURIComponent(
JSON.stringify(cloned_action.context));
new_url +=
"?options=" +
encodeURIComponent(JSON.stringify(cloned_action.data));
new_url +=
"&context=" +
encodeURIComponent(JSON.stringify(cloned_action.context));
}
return new Promise(function(resolve, reject) {
@ -38,8 +41,8 @@ odoo.define("report_xlsx.report", function (require) {
data: JSON.stringify([new_url, type]),
},
success: resolve,
error: (error) => {
self.call('crash_manager', 'rpc_error', error);
error: error => {
self.call("crash_manager", "rpc_error", error);
reject();
},
complete: framework.unblockUI,
@ -48,10 +51,12 @@ odoo.define("report_xlsx.report", function (require) {
// AAB: this check should be done in get_file service directly,
// should not be the concern of the caller (and that way, get_file
// could return a deferred)
var message = _t('A popup window with your report was blocked. You ' +
'may need to change your browser settings to allow ' +
'popup windows for this page.');
this.do_warn(_t('Warning'), message, true);
var message = _t(
"A popup window with your report was blocked. You " +
"may need to change your browser settings to allow " +
"popup windows for this page."
);
this.do_warn(_t("Warning"), message, true);
}
});
},
@ -63,29 +68,31 @@ odoo.define("report_xlsx.report", function (require) {
return this._downloadReportXLSX(reportUrls[type], action).then(
function() {
if (action.close_on_report_download) {
var closeAction = {type: 'ir.actions.act_window_close'};
return self.doAction(closeAction, _.pick(
options, 'on_close'));
var closeAction = {type: "ir.actions.act_window_close"};
return self.doAction(
closeAction,
_.pick(options, "on_close")
);
}
return options.on_close();
});
}
);
}
return this._super.apply(this, arguments);
},
_makeReportUrls: function(action) {
var reportUrls = this._super.apply(this, arguments);
reportUrls.xlsx = '/report/xlsx/' + action.report_name;
reportUrls.xlsx = "/report/xlsx/" + action.report_name;
return reportUrls;
},
_executeReportAction: function(action, options) {
var self = this;
if (action.report_type === 'xlsx') {
return self._triggerDownload(action, options, 'xlsx');
if (action.report_type === "xlsx") {
return self._triggerDownload(action, options, "xlsx");
}
return this._super.apply(this, arguments);
},
});
});

6
report_xlsx/views/webclient_templates.xml

@ -6,8 +6,10 @@
-->
<template id="assets_backend" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/report_xlsx/static/src/js/report/action_manager_report.js"/>
<script
type="text/javascript"
src="/report_xlsx/static/src/js/report/action_manager_report.js"
/>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save