feat: prompt qty on scan
This commit is contained in:
parent
d48ab81622
commit
47b4251844
@ -12,6 +12,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
this.qty_field = opts.qty_field || "qty";
|
this.qty_field = opts.qty_field || "qty";
|
||||||
this.max_qty_field = opts.max_qty_field || null;
|
this.max_qty_field = opts.max_qty_field || null;
|
||||||
this.dont_allow_new_row = opts.dont_allow_new_row;
|
this.dont_allow_new_row = opts.dont_allow_new_row;
|
||||||
|
this.prompt_qty = opts.prompt_qty;
|
||||||
|
|
||||||
this.items_table_name = opts.items_table_name || "items";
|
this.items_table_name = opts.items_table_name || "items";
|
||||||
this.items_table = this.frm.doc[this.items_table_name];
|
this.items_table = this.frm.doc[this.items_table_name];
|
||||||
@ -94,9 +95,10 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.show_scan_message(row.idx, row.item_code);
|
|
||||||
this.set_selector_trigger_flag(row, data);
|
this.set_selector_trigger_flag(row, data);
|
||||||
this.set_item(row, item_code);
|
this.set_item(row, item_code).then(qty => {
|
||||||
|
this.show_scan_message(row.idx, row.item_code, qty);
|
||||||
|
});
|
||||||
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);
|
||||||
this.set_barcode(row, barcode);
|
this.set_barcode(row, barcode);
|
||||||
@ -117,9 +119,23 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_item(row, item_code) {
|
set_item(row, item_code) {
|
||||||
const item_data = { item_code: item_code };
|
return new Promise(resolve => {
|
||||||
item_data[this.qty_field] = (row[this.qty_field] || 0) + 1;
|
const increment = (value = 1) => {
|
||||||
frappe.model.set_value(row.doctype, row.name, item_data);
|
const item_data = {item_code: item_code};
|
||||||
|
item_data[this.qty_field] = (row[this.qty_field] || 0) + value;
|
||||||
|
frappe.model.set_value(row.doctype, row.name, item_data);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.prompt_qty) {
|
||||||
|
frappe.prompt(__("Please enter quantity for item {0}", [item_code]), ({value}) => {
|
||||||
|
increment(value);
|
||||||
|
resolve(value);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
increment();
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
set_serial_no(row, serial_no) {
|
set_serial_no(row, serial_no) {
|
||||||
@ -148,12 +164,12 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
show_scan_message(idx, exist = null) {
|
show_scan_message(idx, exist = null, qty = 1) {
|
||||||
// show new row or qty increase toast
|
// show new row or qty increase toast
|
||||||
if (exist) {
|
if (exist) {
|
||||||
frappe.show_alert(
|
frappe.show_alert(
|
||||||
{
|
{
|
||||||
message: __("Row #{0}: Qty increased by 1", [idx]),
|
message: __("Row #{0}: Qty increased by {1}", [idx, qty]),
|
||||||
indicator: "green",
|
indicator: "green",
|
||||||
},
|
},
|
||||||
5
|
5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user