[MIG] report_csv: Migration to 13.0

This commit is contained in:
kongrattapong
2020-02-21 17:19:02 +07:00
committed by ferran-73
parent f9d2d2178a
commit 77665ceaec
7 changed files with 39 additions and 33 deletions

View File

@@ -5,7 +5,6 @@ odoo.define("report_csv.report", function (require) {
var core = require("web.core");
var ActionManager = require("web.ActionManager");
var crash_manager = require("web.crash_manager");
var framework = require("web.framework");
var session = require("web.session");
var _t = core._t;
@@ -13,8 +12,8 @@ odoo.define("report_csv.report", function (require) {
ActionManager.include({
_downloadReportCSV: function (url, actions) {
var self = this;
framework.blockUI();
var def = $.Deferred();
var type = "csv";
var cloned_action = _.clone(actions);
@@ -30,28 +29,29 @@ odoo.define("report_csv.report", function (require) {
url += "&context=" + encodeURIComponent(JSON.stringify(cloned_action.context));
}
var blocked = !session.get_file({
url: url,
data: {
data: JSON.stringify([url, type]),
},
success: def.resolve.bind(def),
error: function () {
crash_manager.rpc_error.apply(crash_manager, arguments);
def.reject();
},
complete: framework.unblockUI,
return new Promise(function (resolve, reject) {
var blocked = !session.get_file({
url: url,
data: {
data: JSON.stringify([url, type]),
},
success: resolve,
error: (error) => {
self.call('crash_manager', 'rpc_error', error);
reject();
},
complete: framework.unblockUI,
});
if (blocked) {
// 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);
}
});
if (blocked) {
// 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);
}
return def;
},
_triggerDownload: function (action, options, type) {