diff --git a/addons/website_sale/static/src/js/sale_variant_mixin.js b/addons/website_sale/static/src/js/sale_variant_mixin.js index 88769fe2e55..0eb37375624 100644 --- a/addons/website_sale/static/src/js/sale_variant_mixin.js +++ b/addons/website_sale/static/src/js/sale_variant_mixin.js @@ -79,6 +79,9 @@ var VariantMixin = { 'context': this.context, ...this._getOptionalCombinationInfoParam($currentOptionalProduct), }).then((combinationData) => { + if (this._shouldIgnoreRpcResult()) { + return; + } this._onChangeCombination(ev, $currentOptionalProduct, combinationData); this._checkExclusions($currentOptionalProduct, childCombination, combinationData.parent_exclusions); }); @@ -98,6 +101,9 @@ var VariantMixin = { 'context': this.context, ...this._getOptionalCombinationInfoParam($parent), }).then((combinationData) => { + if (this._shouldIgnoreRpcResult()) { + return; + } this._onChangeCombination(ev, $parent, combinationData); this._checkExclusions($parent, combination, combinationData.parent_exclusions); }); @@ -721,6 +727,18 @@ var VariantMixin = { .addClass("active"); }, + /** + * Return true if the current object has been destroyed. + * This function has been added as a fix to know if the result of a rpc + * should be handled. Indeed, "this._rpc()" can not be used as it is not + * supported by some elements that use this mixin. + * + * @private + */ + _shouldIgnoreRpcResult() { + return (typeof this.isDestroyed === "function" && this.isDestroyed()); + }, + /** * Extension point for website_sale *