From dd201b0797b28fc4a52019aee6c03f75b27323b5 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 25 Apr 2019 13:03:50 +0530 Subject: [PATCH] fix: Order Item attribute values dynamically --- erpnext/portal/product_configurator/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/portal/product_configurator/utils.py b/erpnext/portal/product_configurator/utils.py index 43e6fe536f..405a6d8c31 100644 --- a/erpnext/portal/product_configurator/utils.py +++ b/erpnext/portal/product_configurator/utils.py @@ -167,8 +167,13 @@ def get_attributes_and_values(item_code): if attribute in attribute_list: valid_options.setdefault(attribute, set()).add(attribute_value) + item_attribute_values = frappe.db.get_all('Item Attribute Value', + ['parent', 'attribute_value', 'idx'], order_by='parent asc, idx asc') + ordered_attribute_value_map = frappe._dict() + for iv in item_attribute_values: + ordered_attribute_value_map.setdefault(iv.parent, []).append(iv.attribute_value) + # build attribute values in idx order - ordered_attribute_value_map = item_cache.get_ordered_attribute_values() for attr in attributes: valid_attribute_values = valid_options.get(attr.attribute, []) ordered_values = ordered_attribute_value_map.get(attr.attribute, [])