diff --git a/addons/web/static/src/js/core/ajax.js b/addons/web/static/src/js/core/ajax.js index fa79c65ef45..81643e99430 100644 --- a/addons/web/static/src/js/core/ajax.js +++ b/addons/web/static/src/js/core/ajax.js @@ -4,6 +4,10 @@ odoo.define('web.ajax', function (require) { var core = require('web.core'); var utils = require('web.utils'); var time = require('web.time'); +var download = require('web.download'); +var contentdisposition = require('web.contentdisposition'); + +var _t = core._t; function genericJsonRpc (fct_name, params, settings, fct) { var shadow = settings.shadow || false; @@ -269,120 +273,85 @@ var loadJS = (function () { * changed to make it work. */ function get_file(options) { - // need to detect when the file is done downloading (not used - // yet, but we'll need it to fix the UI e.g. with a throbber - // while dump is being generated), iframe load event only fires - // when the iframe content loads, so we need to go smarter: - // http://geekswithblogs.net/GruffCode/archive/2010/10/28/detecting-the-file-download-dialog-in-the-browser.aspx - var timer, token = new Date().getTime(), - cookie_name = 'fileToken', cookie_length = cookie_name.length, - CHECK_INTERVAL = 1000, id = _.uniqueId('get_file_frame'), - remove_form = false; - - - // iOS devices doesn't allow iframe use the way we do it, - // opening a new window seems the best way to workaround - if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { - var params = _.extend({}, options.data || {}, {token: token}); - var url = options.session.url(options.url, params); - if (options.complete) { options.complete(); } - - var w = window.open(url); - if (!w || w.closed || typeof w.closed === 'undefined') { - // popup was blocked - return false; - } - return true; - } - - var $form, $form_data = $('
'); - - var complete = function () { - if (options.complete) { options.complete(); } - clearTimeout(timer); - $form_data.remove(); - $target.remove(); - if (remove_form && $form) { $form.remove(); } - }; - var $target = $('