From 331e1f70ec143a8a0f42acabb034abff1e6559ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Mon, 9 Sep 2019 12:54:41 +0000 Subject: [PATCH] [IMP] (website_)sale(_comparison): remove 12.0 compatibility code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This code was introduced for fixes in stable version but it is not used now. closes odoo/odoo#36365 Signed-off-by: Sébastien Theys (seb) --- addons/sale/static/src/js/variant_mixin.js | 11 +--- .../static/src/js/website_sale.js | 61 ++++--------------- addons/website_sale/views/templates.xml | 4 +- .../website_sale_comparison_template.xml | 8 +-- 4 files changed, 17 insertions(+), 67 deletions(-) diff --git a/addons/sale/static/src/js/variant_mixin.js b/addons/sale/static/src/js/variant_mixin.js index b03d3c623c8..147a54a5e79 100644 --- a/addons/sale/static/src/js/variant_mixin.js +++ b/addons/sale/static/src/js/variant_mixin.js @@ -301,11 +301,6 @@ var VariantMixin = { JSON.stringify(self.getSelectedVariantValues($container)), }; - // Note about 12.0 compatibility: this route will not exist if - // updating the code but not restarting the server. (404) - // We don't handle that compatibility because the previous code was - // not working either: it was making an RPC that failed with any - // non-admin user anyway. To use this feature, restart the server. var route = '/sale/create_product_variant'; if (useAjax) { productReady = ajax.jsonRpc(route, 'call', params); @@ -458,11 +453,7 @@ var VariantMixin = { } this._toggleDisable($parent, isCombinationPossible); - - // compatibility_check to remove in master - // needed for fix in 12.0 in the case of git pull and no server restart - var compatibility_check = combination.list_price - combination.price >= 0.01; - if (combination.has_discounted_price !== undefined ? combination.has_discounted_price : compatibility_check) { + if (combination.has_discounted_price) { $default_price .closest('.oe_website_sale') .addClass("discount"); diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 9ce94c90448..ef636055df4 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -414,56 +414,21 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, { * @override * @private */ - _updateProductImage: function ($productContainer, displayImage, productId, productTemplateId, new_carousel, isCombinationPossible) { - var $img; + _updateProductImage: function ($productContainer, displayImage, productId, productTemplateId, newCarousel, isCombinationPossible) { var $carousel = $productContainer.find('#o-carousel-product'); - - if (isCombinationPossible === undefined) { - isCombinationPossible = this.isSelectedVariantAllowed; + // When using the web editor, don't reload this or the images won't + // be able to be edited depending on if this is done loading before + // or after the editor is ready. + if (window.location.search.indexOf('enable_editor') === -1) { + var $newCarousel = $(newCarousel); + $carousel.after($newCarousel); + $carousel.remove(); + $carousel = $newCarousel; + $carousel.carousel(0); + this._startZoom(); + // fix issue with carousel height + this.trigger_up('widgets_start_request', {$target: $carousel}); } - - if (new_carousel) { - // When using the web editor, don't reload this or the images won't - // be able to be edited depending on if this is done loading before - // or after the editor is ready. - if (window.location.search.indexOf('enable_editor') === -1) { - var $new_carousel = $(new_carousel); - $carousel.after($new_carousel); - $carousel.remove(); - $carousel = $new_carousel; - $carousel.carousel(0); - this._startZoom(); - // fix issue with carousel height - this.trigger_up('widgets_start_request', {$target: $carousel}); - } - } - else { // compatibility 12.0 - var model = productId ? 'product.product' : 'product.template'; - var modelId = productId || productTemplateId; - var imageSrc = '/web/image/{0}/{1}/image_1024' - .replace("{0}", model) - .replace("{1}", modelId); - - $img = $productContainer.find('img.js_variant_img'); - $img.attr("src", imageSrc); - $img.parent().attr('data-oe-model', model).attr('data-oe-id', modelId) - .data('oe-model', model).data('oe-id', modelId); - - var $thumbnail = $productContainer.find('img.js_variant_img_small'); - if ($thumbnail.length !== 0) { // if only one, thumbnails are not displayed - $thumbnail.attr("src", "/web/image/{0}/{1}/image_128/90x90" - .replace('{0}', model) - .replace('{1}', modelId)); - $('.carousel').carousel(0); - } - - // reset zooming constructs - $img.filter('[data-zoom-image]').attr('data-zoom-image', $img.attr('src')); - if ($img.data('zoomOdoo') !== undefined) { - $img.data('zoomOdoo').isReady = false; - } - } - $carousel.toggleClass('css_not_available', !isCombinationPossible); }, /** diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index c16b7862491..6e1eab7c323 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -1011,9 +1011,7 @@
- - - + diff --git a/addons/website_sale_comparison/views/website_sale_comparison_template.xml b/addons/website_sale_comparison/views/website_sale_comparison_template.xml index 0d00ca84e06..6233bed257b 100644 --- a/addons/website_sale_comparison/views/website_sale_comparison_template.xml +++ b/addons/website_sale_comparison/views/website_sale_comparison_template.xml @@ -120,9 +120,7 @@ Price: - - - + @@ -166,9 +164,7 @@

- - - +