From b8a5646426f386c3dfb6747f3b9583a17396dc62 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Wed, 28 Jan 2015 10:06:35 +0100 Subject: [PATCH] [FIX] hide product attribute value in POS if value has no product associated to it --- pos_product_template/static/src/js/ppt.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pos_product_template/static/src/js/ppt.js b/pos_product_template/static/src/js/ppt.js index 5eb0438b..e46875dc 100644 --- a/pos_product_template/static/src/js/ppt.js +++ b/pos_product_template/static/src/js/ppt.js @@ -333,17 +333,20 @@ Define: pos_product_template.AttributeListWidget var list_container = attribute_node.querySelector('.value-list'); for(var i = 0, len = attribute.value_ids.length; i < len; i++){ var value = this.pos.db.get_product_attribute_value_by_id(attribute.value_ids[i]); - var value_node = this.render_value(attribute, value); - value_node.addEventListener('click', this.click_set_attribute_handler); - list_container.appendChild(value_node); + var product_list = this.pos.db.get_product_by_ids(this.product_template.product_variant_ids); + var subproduct_list = this.pos.db.get_product_by_value_and_products(value.id, product_list); + var variant_qty = subproduct_list.length; + // Hide product attribute value if there is no product associated to it + if (variant_qty != 0) { + var value_node = this.render_value(value, variant_qty); + value_node.addEventListener('click', this.click_set_attribute_handler); + list_container.appendChild(value_node); + } }; return attribute_node; }, - render_value: function(attribute, value){ - product_list = this.pos.db.get_product_by_ids(this.product_template.product_variant_ids); - subproduct_list = this.pos.db.get_product_by_value_and_products(value.id, product_list); - variant_qty = subproduct_list.length; + render_value: function(value, variant_qty){ var value_html = QWeb.render('AttributeValueWidget',{ widget: this, value: value,