summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-10-16 14:32:59 +0200
committerGéry Debongnie <ged@odoo.com>2017-10-16 14:47:29 +0200
commita18a3fd31a9217325c8709613544591ec71272cc (patch)
tree1fa4ea8d74c93712df4b9d67d7c4a77a3f2c3570 /addons/web
parent8191d6d72e82282c3ea4547d02bfd6ee9fa5022b (diff)
[FIX] web,report: display warning when report download is blocked
iOS devices need to open a window to allow downloading files. This is fine, unless the browser is setup to block the popups, which is quite probably the default settings. In that case, it just fails silently, and the user has no idea of what just happened. So, with this commit, we simply display a warning to let the user know of what is actually going on.
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/static/src/js/core/ajax.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/web/static/src/js/core/ajax.js b/addons/web/static/src/js/core/ajax.js
index dee6f4599b4..fe9b00203ce 100644
--- a/addons/web/static/src/js/core/ajax.js
+++ b/addons/web/static/src/js/core/ajax.js
@@ -212,6 +212,9 @@ var loadJS = (function () {
* @param {Function} [options.success] callback in case of download success
* @param {Function} [options.error] callback in case of request error, provided with the error body
* @param {Function} [options.complete] called after both ``success`` and ``error` callbacks have executed
+ * @returns {boolean} a false value means that a popup window was blocked. This
+ * mean that we probably need to inform the user that something needs to be
+ * changed to make it work.
*/
function get_file(options) {
// need to detect when the file is done downloading (not used
@@ -232,7 +235,12 @@ function get_file(options) {
var url = options.session.url(options.url, params);
if (options.complete) { options.complete(); }
- return window.open(url);
+ var w = window.open(url);
+ if (!w || w.closed || typeof w.closed === 'undefined') {
+ // popup was blocked
+ return false;
+ }
+ return true;
}
var $form, $form_data = $('<div>');
@@ -309,6 +317,7 @@ function get_file(options) {
}
};
timer = setTimeout(waitLoop, CHECK_INTERVAL);
+ return true;
};
function post (controller_url, data) {