Merge pull request #13404 from pratu16x7/variants

Enumerate numeric values in variant dialog
This commit is contained in:
Prateeksha Singh 2018-03-27 12:18:13 +05:30 committed by GitHub
commit ffaed1ce2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -444,27 +444,48 @@ $.extend(erpnext.item, {
return selected_attributes; return selected_attributes;
} }
let attribute_names = frm.doc.attributes.map(d => d.attribute); frm.doc.attributes.forEach(function(d) {
attribute_names.forEach(function(attribute) {
let p = new Promise(resolve => { let p = new Promise(resolve => {
frappe.call({ if(!d.numeric_values) {
method:"frappe.client.get_list", frappe.call({
args:{ method:"frappe.client.get_list",
doctype:"Item Attribute Value", args:{
filters: [ doctype:"Item Attribute Value",
["parent","=", attribute] filters: [
], ["parent","=", d.attribute]
fields: ["attribute_value"], ],
limit_start: 0, fields: ["attribute_value"],
limit_page_length: 500 limit_start: 0,
} limit_page_length: 500
}).then((r) => { }
if(r.message) { }).then((r) => {
attr_val_fields[attribute] = r.message.map(function(d) { return d.attribute_value; }); if(r.message) {
resolve(); 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); promises.push(p);