[fix] Don't add newline at the end, onchange of serial_no and filter warehouse based on company and is_group (#9809)

This commit is contained in:
Nabin Hait 2017-07-12 14:10:43 +05:30 committed by Rushabh Mehta
parent f012a9db70
commit 79c2191aa3
2 changed files with 14 additions and 8 deletions

View File

@ -338,7 +338,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
this.frm.trigger("item_code", cdt, cdn);
}
else {
var sr_no = [];
var valid_serial_nos = [];
// Replacing all occurences of comma with carriage return
var serial_nos = item.serial_no.trim().replace(/,/g, '\n');
@ -347,21 +347,19 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
// Trim each string and push unique string to new list
for (var x=0; x<=serial_nos.length - 1; x++) {
if (serial_nos[x].trim() != "" && sr_no.indexOf(serial_nos[x].trim()) == -1) {
sr_no.push(serial_nos[x].trim());
if (serial_nos[x].trim() != "" && valid_serial_nos.indexOf(serial_nos[x].trim()) == -1) {
valid_serial_nos.push(serial_nos[x].trim());
}
}
// Add the new list to the serial no. field in grid with each in new line
item.serial_no = "";
for (var x=0; x<=sr_no.length - 1; x++)
item.serial_no += sr_no[x] + '\n';
item.serial_no = valid_serial_nos.join('\n');
refresh_field("serial_no", item.name, item.parentfield);
if(!doc.is_return) {
frappe.model.set_value(item.doctype, item.name,
"qty", sr_no.length / item.conversion_factor);
frappe.model.set_value(item.doctype, item.name, "stock_qty", sr_no.length);
"qty", valid_serial_nos.length / item.conversion_factor);
frappe.model.set_value(item.doctype, item.name, "stock_qty", valid_serial_nos.length);
}
}
}

View File

@ -50,6 +50,14 @@ erpnext.SerialNoBatchSelector = Class.extend({
batches.grid.refresh();
batches.grid.add_new_row(null, null, null);
}
},
get_query: function() {
return {
filters: {
is_group: 0,
company: me.frm.doc.company
}
};
}
},
{fieldtype:'Column Break'},