From ab56e637b7f97ddcdbcc9baea99ae097e342409c Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Wed, 6 Mar 2019 14:02:32 +0100 Subject: [REF] web: adapt code after jQuery update Part of task 1896658 Co-authored-by: Aaron Bohy Co-authored-by: Christophe Matthieu Co-authored-by: Mathieu Duckerts-Antoine Co-authored-by: David Monjoie Co-authored-by: Martin Geubelle Co-authored-by: svs-odoo Co-authored-by: Vincent Schippefilt --- .../web/static/src/js/widgets/attach_document.js | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'addons/web/static/src/js/widgets/attach_document.js') diff --git a/addons/web/static/src/js/widgets/attach_document.js b/addons/web/static/src/js/widgets/attach_document.js index 13496f3aea7..3175875c151 100644 --- a/addons/web/static/src/js/widgets/attach_document.js +++ b/addons/web/static/src/js/widgets/attach_document.js @@ -108,26 +108,27 @@ var AttachDocument = Widget.extend({ * @private */ _onFileLoaded: function () { - var self = this, - def = $.Deferred(); - - if (self.node.attrs.action) { - // the first argument isn't a file but the jQuery.Event - var files = Array.prototype.slice.call(arguments, 1); - self._rpc({ - model: self.res_model, - method: self.node.attrs.action, - args: [self.res_id], - kwargs: { - 'attachment_ids': _.map(files, function (file) {return file.id;}), - } - }).then( function () { - def.resolve(); - }); - } else { - def.resolve(); - } - return $.when(def).then(function () { + var self = this; + return new Promise(function (resolve) { + if (self.node.attrs.action) { + // the first argument isn't a file but the jQuery.Event + var files = Array.prototype.slice.call(arguments, 1); + self._rpc({ + model: self.res_model, + method: self.node.attrs.action, + args: [self.res_id], + kwargs: { + attachment_ids: _.map(files, function (file) { + return file.id; + }), + } + }).then(function () { + resolve(); + }); + } else { + resolve(); + } + }).then(function () { self.trigger_up('reload'); framework.unblockUI(); }); -- cgit v1.2.3