From f810e003325ece2a6e88b33d099d288d86992e3f Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 16 Apr 2021 15:01:07 +0000 Subject: [PATCH] [FIX] sale: no show single novariant attribute in configurator A product with single novariant attribute is normally not shown. But in the configurator modal it was shown and then added in the product description when doing exactly the same scenario (add the product) than without the configurator. With this changeset, we add is_single attribute and only add a no_create variant if it is not a single value or a custom value. opw-2494331 closes odoo/odoo#70700 X-original-commit: 9bd32f2a36eae1713753bf7a5a1aee3b5c51a97a Signed-off-by: Nicolas Lempereur (nle) --- addons/sale/static/src/js/variant_mixin.js | 3 ++- addons/sale/views/variant_templates.xml | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/sale/static/src/js/variant_mixin.js b/addons/sale/static/src/js/variant_mixin.js index 6a2e4aeb9f1..4447be0ada0 100644 --- a/addons/sale/static/src/js/variant_mixin.js +++ b/addons/sale/static/src/js/variant_mixin.js @@ -224,12 +224,13 @@ var VariantMixin = { $container.find(variantsValuesSelectors.join(',')).each(function (){ var $variantValueInput = $(this); + var singleNoCustom = $variantValueInput.data('is_single') && !$variantValueInput.data('is_custom'); if ($variantValueInput.is('select')){ $variantValueInput = $variantValueInput.find('option[value=' + $variantValueInput.val() + ']'); } - if ($variantValueInput.length !== 0){ + if ($variantValueInput.length !== 0 && !singleNoCustom){ noVariantAttributeValues.push({ 'custom_product_template_attribute_value_id': $variantValueInput.data('value_id'), 'attribute_value_name': $variantValueInput.data('value_name'), diff --git a/addons/sale/views/variant_templates.xml b/addons/sale/views/variant_templates.xml index e089e7aff97..08ba630ca68 100644 --- a/addons/sale/views/variant_templates.xml +++ b/addons/sale/views/variant_templates.xml @@ -10,7 +10,8 @@ t-attf-class="variant_attribute #{'d-none' if len(ptal.product_template_value_ids._only_active()) == 1 and not ptal.product_template_value_ids._only_active()[0].is_custom else ''}"> - + + @@ -25,6 +26,7 @@ t-att-data-attribute_name="ptav.attribute_id.name" t-att-data-is_custom="ptav.is_custom" t-att-selected="ptav in combination" + t-att-data-is_single="single" t-att-data-is_single_and_custom="single_and_custom"> @@ -65,6 +67,7 @@ t-att-data-value_name="ptav.name" t-att-data-attribute_name="ptav.attribute_id.name" t-att-data-is_custom="ptav.is_custom" + t-att-data-is_single="single" t-att-data-is_single_and_custom="single_and_custom" />
@@ -119,6 +122,7 @@ t-att-data-value_name="ptav.name" t-att-data-attribute_name="ptav.attribute_id.name" t-att-data-is_custom="ptav.is_custom" + t-att-data-is_single="single" t-att-data-is_single_and_custom="single_and_custom"/>