[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) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2019-04-19 11:17:56 +00:00
parent bf1e39540f
commit a742bf3d5b
@@ -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 = $('<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 () {});
},
/**