From 2656bcf55d498d9adc30297b806797f0ebb0e3bf Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Tue, 16 Aug 2022 08:35:57 +0000 Subject: [PATCH] [FIX] website_sale_wishlist: fix undeterministic error in tour This commit attempts to fix an undeterministic error during one of `website_sale_wishlist` tests. Due to a race condition it may happen that the button to add to the wishlist would be re enabled while it should be disabled (if the product is already in the wishlist) causing the tour to fail. closes odoo/odoo#98206 X-original-commit: e10f50e6eb3b825113058d29ae79c7aeafd94a55 Signed-off-by: William Braeckman (wbr) --- .../static/src/js/website_sale_wishlist.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js index 1482dffca4d..2bf39d9ee30 100644 --- a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js +++ b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js @@ -109,6 +109,16 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(VariantMixin, sessionStorage.setItem('website_sale_wishlist_product_ids', JSON.stringify(self.wishlistProductIDs)); self._updateWishlistView(); wSaleUtils.animateClone($navButton, $el.closest('form'), 25, 40); + // It might happen that `onChangeVariant` is called at the same time as this function. + // In this case we need to set the button to disabled again. + // Do this only if the productID is still the same. + let currentProductId = $el.data('product-product-id'); + if ($el.hasClass('o_add_wishlist_dyn')) { + currentProductId = parseInt($el.closest('.js_product').find('.product_id:checked').val()); + } + if (productId === currentProductId) { + $el.prop("disabled", true).addClass('disabled'); + } }).guardedCatch(function () { $el.prop("disabled", false).removeClass('disabled'); });