From a742bf3d5bd3d613cc792339b910ac0f5143e2d7 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 8 Apr 2019 05:33:21 +0000 Subject: [PATCH] [FIX] website_sale: fix double click on add to cart Using "async" in the event parameter is not enough, you have to return correct promises in the event handlers. closes odoo/odoo#32479 Signed-off-by: Quentin Smetz (qsm) --- addons/website_sale/static/src/js/website_sale.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 317dc513d5c..efac0663add 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -458,7 +458,7 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, { false ); - productReady.then(function (productId){ + return productReady.then(function (productId) { $form.find(productSelector.join(', ')).val(productId); self.rootProduct = { @@ -471,12 +471,10 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, { return self._onProductReady(); }); - - return productReady; }, _onProductReady: function () { - this._submitForm(); + return this._submitForm(); }, /** @@ -484,6 +482,7 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, { * in the form data and trigger submit. * * @private + * @returns {Promise} never resolved */ _submitForm: function () { var $productCustomVariantValues = $('', { @@ -501,6 +500,8 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, { this.$form.append($productNoVariantAttributeValues); this.$form.trigger('submit', [true]); + + return new Promise(function () {}); }, /**