feat: dont trigger selector if all info is scanned
This commit is contained in:
committed by
Ankush Menat
parent
47f27a5171
commit
6a069d6efa
@@ -526,6 +526,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
if(!d[k]) d[k] = v;
|
if(!d[k]) d[k] = v;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (d.__disable_batch_serial_selector) {
|
||||||
|
// reset for future use.
|
||||||
|
d.__disable_batch_serial_selector = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (d.has_batch_no && d.has_serial_no) {
|
if (d.has_batch_no && d.has_serial_no) {
|
||||||
d.batch_no = undefined;
|
d.batch_no = undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,14 +50,16 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
me.update_table(data.item_code, data.barcode, data.batch_no, data.serial_no);
|
me.update_table(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update_table(item_code, barcode, batch_no, serial_no) {
|
update_table(data) {
|
||||||
let cur_grid = this.frm.fields_dict[this.items_table_name].grid;
|
let cur_grid = this.frm.fields_dict[this.items_table_name].grid;
|
||||||
let row = null;
|
let row = null;
|
||||||
|
|
||||||
|
const {item_code, barcode, batch_no, serial_no} = data;
|
||||||
|
|
||||||
// Check if batch is scanned and table has batch no field
|
// Check if batch is scanned and table has batch no field
|
||||||
let batch_no_scan =
|
let batch_no_scan =
|
||||||
Boolean(batch_no) && frappe.meta.has_field(cur_grid.doctype, this.batch_no_field);
|
Boolean(batch_no) && frappe.meta.has_field(cur_grid.doctype, this.batch_no_field);
|
||||||
@@ -82,6 +84,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.show_scan_message(row.idx, row.item_code);
|
this.show_scan_message(row.idx, row.item_code);
|
||||||
|
this.set_selector_trigger_flag(row, data);
|
||||||
this.set_item(row, item_code);
|
this.set_item(row, item_code);
|
||||||
this.set_serial_no(row, serial_no);
|
this.set_serial_no(row, serial_no);
|
||||||
this.set_batch_no(row, batch_no);
|
this.set_batch_no(row, batch_no);
|
||||||
@@ -89,6 +92,19 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
this.clean_up();
|
this.clean_up();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// batch and serial selector is reduandant when all info can be added by scan
|
||||||
|
// this flag on item row is used by transaction.js to avoid triggering selector
|
||||||
|
set_selector_trigger_flag(row, data) {
|
||||||
|
const {batch_no, serial_no, has_batch_no, has_serial_no} = data;
|
||||||
|
|
||||||
|
const require_selecting_batch = has_batch_no && !batch_no;
|
||||||
|
const require_selecting_serial = has_serial_no && !serial_no;
|
||||||
|
|
||||||
|
if (!(require_selecting_batch || require_selecting_serial)) {
|
||||||
|
row.__disable_batch_serial_selector = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set_item(row, item_code) {
|
set_item(row, item_code) {
|
||||||
const item_data = { item_code: item_code };
|
const item_data = { item_code: item_code };
|
||||||
item_data[this.qty_field] = (row[this.qty_field] || 0) + 1;
|
item_data[this.qty_field] = (row[this.qty_field] || 0) + 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user