From b46cdbbda47bb0d53babf62d72b1442cf876a19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 22 Mar 2019 11:03:31 +0000 Subject: [PATCH] [FIX] website_sale: fix forward-port of product configurator The method `onChangeVariant` was overridden in 12.2 to fix an issue with the new web editor and separately overridden in 12.0 to fix an issue with the product configurator. After the forward-port, the method was defined twice, and only the second was taken into account. This commit fixes it by merging the two methods. closes odoo/odoo#32041 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/website_sale.js | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index ec883d9025b..61216b26bd7 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -211,24 +211,6 @@ sAnimations.registry.WebsiteSale = sAnimations.Class.extend(ProductConfiguratorM } return ProductConfiguratorMixin.getSelectedVariantValues.apply(this, arguments); }, - /** - * Write the properties of the form elements in the DOM to prevent the - * current selection from being lost when activating the web editor. - * - * @override - */ - onChangeVariant: function (ev) { - var $component = $(ev.currentTarget).closest('.js_product'); - $component.find('input').each(function () { - var $el = $(this); - $el.attr('checked', $el.is(':checked')); - }); - $component.find('select option').each(function () { - var $el = $(this); - $el.attr('selected', $el.is(':selected')); - }); - return ProductConfiguratorMixin.onChangeVariant.apply(this, arguments); - }, //-------------------------------------------------------------------------- // Private @@ -601,9 +583,11 @@ sAnimations.registry.WebsiteSale = sAnimations.Class.extend(ProductConfiguratorM $('.ship_to_other').toggle(!$(ev.currentTarget).prop('checked')); }, /** - * @override - * * Dirty fix: prevent options modal events to be triggered and bubbled + * Also write the properties of the form elements in the DOM to prevent the + * current selection from being lost when activating the web editor. + * + * @override */ onChangeVariant: function (ev, data) { var $originPath = ev.originalEvent && Array.isArray(ev.originalEvent.path) ? $(ev.originalEvent.path) : $(); @@ -612,6 +596,17 @@ sAnimations.registry.WebsiteSale = sAnimations.Class.extend(ProductConfiguratorM ev.stopPropagation(); return; } + + var $component = $(ev.currentTarget).closest('.js_product'); + $component.find('input').each(function () { + var $el = $(this); + $el.attr('checked', $el.is(':checked')); + }); + $component.find('select option').each(function () { + var $el = $(this); + $el.attr('selected', $el.is(':selected')); + }); + return ProductConfiguratorMixin.onChangeVariant.apply(this, arguments); }, /**