summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2021-04-16 15:01:07 +0000
committerNicolas Lempereur <nle@odoo.com>2021-05-11 13:34:19 +0000
commit23f95f05f5f20054e4ff58d320c7634fe1c872ff (patch)
tree91c89c62aeb5d381cf218b90fa3ca4f6441629eb
parentf593cdab18c4700af5d4e04a0aa7c6b367488f70 (diff)
[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#70680 X-original-commit: 9bd32f2a36eae1713753bf7a5a1aee3b5c51a97a Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
-rw-r--r--addons/sale/static/src/js/variant_mixin.js3
-rw-r--r--addons/sale/views/variant_templates.xml6
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 b24e0819d92..3167be11f1c 100644
--- a/addons/sale/static/src/js/variant_mixin.js
+++ b/addons/sale/static/src/js/variant_mixin.js
@@ -231,12 +231,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 019c54558cc..53f46c58d21 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 ''}">
<!-- Used to customize layout if the only available attribute value is custom -->
- <t t-set="single_and_custom" t-value="len(ptal.product_template_value_ids._only_active()) == 1 and ptal.product_template_value_ids._only_active()[0].is_custom" />
+ <t t-set="single" t-value="len(ptal.product_template_value_ids._only_active()) == 1"/>
+ <t t-set="single_and_custom" t-value="single and ptal.product_template_value_ids._only_active()[0].is_custom" />
<strong t-field="ptal.attribute_id.name" class="attribute_name"/>
<t t-if="ptal.attribute_id.display_type == 'select'">
@@ -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">
<span t-field="ptav.name"/>
<span t-if="ptav.price_extra" class="badge badge-pill badge-secondary">
@@ -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" />
<div class="radio_input_value">
<span t-field="ptav.name"/>
@@ -101,6 +104,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"/>
</label>
</li>