summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAurélien Warnon <awa@odoo.com>2018-10-10 06:24:25 +0000
committerAurélien Warnon <awa@odoo.com>2018-10-10 06:24:25 +0000
commitc9041e8dcfbfe93676f4d2cb1bf96e512afbac38 (patch)
treeb30a1ef4df74ec51b906d33dba18634c837ca115 /addons
parent36cadc374b090c88bcccb6e97671336b806645ab (diff)
[FIX] (website_)sale: hide single attribute value in p. configurator
Targets commit d3530eb07e24278117ab396ecb86a59deecc312d References task id 1892022 Purpose ======= - When there is only one attribute value for an attribute configured in a product's variants, it should be hidden in the product configurator. e.g: The only value selected for the "Material" attribute is the "Wood" value for the "Customizable Desk". The radio selection is hidden and "Material: Wood" is displayed in the product's description. - Fixed a class name typo closes odoo/odoo#27604
Diffstat (limited to 'addons')
-rw-r--r--addons/sale/models/product_product.py2
-rw-r--r--addons/sale/views/sale_product_configurator_templates.xml5
2 files changed, 5 insertions, 2 deletions
diff --git a/addons/sale/models/product_product.py b/addons/sale/models/product_product.py
index 87e160673e9..027a371dc8a 100644
--- a/addons/sale/models/product_product.py
+++ b/addons/sale/models/product_product.py
@@ -75,7 +75,7 @@ class ProductAttributeValue(models.Model):
attribute type is 'Color'.""")
-class ProductProductAttributeValue(models.Model):
+class ProductTemplateAttributeValue(models.Model):
_inherit = "product.template.attribute.value"
html_color = fields.Char('HTML Color Index', related="product_attribute_value_id.html_color")
diff --git a/addons/sale/views/sale_product_configurator_templates.xml b/addons/sale/views/sale_product_configurator_templates.xml
index 99c89a03f29..5dcb37fc8e1 100644
--- a/addons/sale/views/sale_product_configurator_templates.xml
+++ b/addons/sale/views/sale_product_configurator_templates.xml
@@ -177,7 +177,10 @@
<t t-set="attribute_exclusions" t-value="get_attribute_exclusions(product, reference_product)"/>
<ul t-attf-class="list-unstyled js_add_cart_variants #{ul_class}" t-att-data-attribute_exclusions="json.dumps(attribute_exclusions)">
<t t-foreach="product.attribute_line_ids.sorted(key=lambda x: x.attribute_id.sequence)" t-as="variant_id">
- <li t-att-data-attribute_id="variant_id.attribute_id.id" t-att-data-attribute_name="variant_id.attribute_id.name" class="variant_attribute">
+ <!-- Attributes selection is hidden if there is only one value available and it's not a custom value -->
+ <li t-att-data-attribute_id="variant_id.attribute_id.id"
+ t-att-data-attribute_name="variant_id.attribute_id.name"
+ t-attf-class="variant_attribute #{'d-none' if len(variant_id.product_template_value_ids) == 1 and not variant_id.product_template_value_ids[0].is_custom else ''}">
<strong t-field="variant_id.attribute_id.name" class="attribute_name" />