use set_value() for setting rows

This commit is contained in:
pratu16x7 2017-06-27 09:48:28 +05:30
parent 89d001caf3
commit 29cebbb0cd
2 changed files with 22 additions and 7 deletions

View File

@ -124,20 +124,25 @@ erpnext.SerialNoBatchSelector = Class.extend({
},
set_items: function() {
var me = this;
if(this.has_batch) {
this.values.batches.map((batch, i) => {
let item_code_field = {};
let row = (i !== 0) ? this.frm.add_child("items") : this.item;
refresh_field("items");
if(i !== 0) {
// let index = i + me.item.idx - 1;
// let grid_row = me.frm.fields_dict.items.grid.grid_rows[index];
// grid_row.toggle_editable_row();
// grid_row.on_grid_fields_dict.item_code.set_value(this.item_code);
let index = i + me.item.idx - 1;
let grid_row = me.frm.fields_dict.items.grid.grid_rows[index];
grid_row.toggle_editable_row();
item_code_field = grid_row.on_grid_fields_dict.item_code;
row.item_code = this.item_code;
}
this.map_row_values(row, batch, 'batch_no',
this.map_row_values(row, batch, 'batch_no',
'selected_qty', this.values.warehouse, item_code_field);
} else {
this.map_row_values(row, batch, 'batch_no',
'selected_qty', this.values.warehouse);
}
});
} else {
this.map_row_values(this.item, this.values, 'serial_no', 'qty');
@ -145,7 +150,7 @@ erpnext.SerialNoBatchSelector = Class.extend({
refresh_field("items");
},
map_row_values: function(row, values, number, qty_field, warehouse) {
map_row_values: function(row, values, number, qty_field, warehouse, item_code_field) {
row.qty = values[qty_field];
row[number] = values[number];
if(this.warehouse_details.type === 'Source Warehouse') {
@ -156,6 +161,11 @@ erpnext.SerialNoBatchSelector = Class.extend({
row.warehouse = values.warehouse || warehouse;
}
if(item_code_field) {
item_code_field.set_value(this.item_code);
// frappe.model.set_value(row.doctype, row.name, 'item_code', this.item_code);
}
},
bind_qty: function() {

View File

@ -172,7 +172,12 @@ frappe.ui.form.on('Stock Entry Detail', {
callback: function(r) {
if(r.message) {
var d = locals[cdt][cdn];
// Properties set possibly via batch modal
var presets = ["batch_no", "qty", "s_warehouse", "t_warehouse"];
$.each(r.message, function(k, v) {
if(presets.includes(k) && d[k]) {
return;
}
d[k] = v;
});
erpnext.stock.select_batch_and_serial_no(frm, d);