From be368fe94b1552164e60af8092f0b7a5249588af Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Tue, 27 Mar 2018 12:16:56 +0530 Subject: [PATCH] Enumerate numeric values in variant dialog --- erpnext/stock/doctype/item/item.js | 61 ++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 90921764c5..cd343fbbdf 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -444,27 +444,48 @@ $.extend(erpnext.item, { return selected_attributes; } - let attribute_names = frm.doc.attributes.map(d => d.attribute); - - attribute_names.forEach(function(attribute) { + frm.doc.attributes.forEach(function(d) { let p = new Promise(resolve => { - frappe.call({ - method:"frappe.client.get_list", - args:{ - doctype:"Item Attribute Value", - filters: [ - ["parent","=", attribute] - ], - fields: ["attribute_value"], - limit_start: 0, - limit_page_length: 500 - } - }).then((r) => { - if(r.message) { - attr_val_fields[attribute] = r.message.map(function(d) { return d.attribute_value; }); - resolve(); - } - }); + if(!d.numeric_values) { + frappe.call({ + method:"frappe.client.get_list", + args:{ + doctype:"Item Attribute Value", + filters: [ + ["parent","=", d.attribute] + ], + fields: ["attribute_value"], + limit_start: 0, + limit_page_length: 500 + } + }).then((r) => { + if(r.message) { + attr_val_fields[d.attribute] = r.message.map(function(d) { return d.attribute_value; }); + resolve(); + } + }); + } else { + frappe.call({ + method:"frappe.client.get", + args:{ + doctype:"Item Attribute", + name: d.attribute + } + }).then((r) => { + if(r.message) { + const from = r.message.from_range; + const to = r.message.to_range; + const increment = r.message.increment; + + let values = []; + for(var i = from; i <= to; i += increment) { + values.push(i); + } + attr_val_fields[d.attribute] = values; + resolve(); + } + }); + } }); promises.push(p);