Skip to content
Permalink
Browse files

[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.
  • Loading branch information...
qsm-odoo committed Apr 8, 2019
1 parent 8c37747 commit a88d27017ec663ce30c80a76d171109738eb37eb
Showing with 5 additions and 4 deletions.
  1. +5 −4 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,19 +471,18 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, {

return self._onProductReady();
});

return productReady;
},

_onProductReady: function () {
this._submitForm();
return this._submitForm();
},

/**
* Add custom variant values and attribute values that do not generate variants
* in the form data and trigger submit.
*
* @private
* @returns {Promise} never resolved
*/
_submitForm: function () {
var $productCustomVariantValues = $('<input>', {
@@ -501,6 +500,8 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, {
this.$form.append($productNoVariantAttributeValues);

this.$form.trigger('submit', [true]);

return new Promise(function () {});
},

/**

0 comments on commit a88d270

Please sign in to comment.
You can’t perform that action at this time.