From 0d21735a92c8d0b60babaac6d62dbc8eda7c11ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Tue, 30 Apr 2019 11:22:32 +0000 Subject: [FIX] web: Send attachment ids on file loaded This commit fixes a bug introduced when migrating from jquery deferred to native JS Promises (ab56e63). Steps to reproduce: 1. Go to the Expense app 2. Create a new expense 3. Click on "Attach Document" and upload a file => crash and infinite loading spinner After loading files, the `attach_document` widget is supposed to call a callback action with attachment ids as argument. Currently, attachement ids are not correclty retrieved. They are retrieved via the `arguments` object but since ab56e63 `arguments` refers to the arguments of the Promise callback function and no longer to the handler function `_onFileLoaded` arguments. closes odoo/odoo#33048 Signed-off-by: VincentSchippefilt --- addons/web/static/src/js/widgets/attach_document.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/widgets/attach_document.js b/addons/web/static/src/js/widgets/attach_document.js index 3175875c151..a4a72a62765 100644 --- a/addons/web/static/src/js/widgets/attach_document.js +++ b/addons/web/static/src/js/widgets/attach_document.js @@ -109,10 +109,10 @@ var AttachDocument = Widget.extend({ */ _onFileLoaded: function () { var self = this; + // the first argument isn't a file but the jQuery.Event + var files = Array.prototype.slice.call(arguments, 1); 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, -- cgit v1.2.3