feat: barcode scanner promise to return scanned row. (#31018)
* feat: barcode scanner promise to return scanned row. * fix: missing reject at alternate code path
This commit is contained in:
parent
a412d2f7e8
commit
d76e1b7576
@ -31,30 +31,39 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process_scan() {
|
process_scan() {
|
||||||
let me = this;
|
return new Promise((resolve, reject) => {
|
||||||
|
let me = this;
|
||||||
|
|
||||||
const input = this.scan_barcode_field.value;
|
const input = this.scan_barcode_field.value;
|
||||||
if (!input) {
|
if (!input) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe
|
frappe
|
||||||
.call({
|
.call({
|
||||||
method: this.scan_api,
|
method: this.scan_api,
|
||||||
args: {
|
args: {
|
||||||
search_value: input,
|
search_value: input,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
const data = r && r.message;
|
const data = r && r.message;
|
||||||
if (!data || Object.keys(data).length === 0) {
|
if (!data || Object.keys(data).length === 0) {
|
||||||
this.show_alert(__("Cannot find Item with this Barcode"), "red");
|
this.show_alert(__("Cannot find Item with this Barcode"), "red");
|
||||||
this.clean_up();
|
this.clean_up();
|
||||||
return;
|
reject();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
me.update_table(data);
|
const row = me.update_table(data);
|
||||||
});
|
if (row) {
|
||||||
|
resolve(row);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update_table(data) {
|
update_table(data) {
|
||||||
@ -90,6 +99,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
this.set_batch_no(row, batch_no);
|
this.set_batch_no(row, batch_no);
|
||||||
this.set_barcode(row, barcode);
|
this.set_barcode(row, barcode);
|
||||||
this.clean_up();
|
this.clean_up();
|
||||||
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
// batch and serial selector is reduandant when all info can be added by scan
|
// batch and serial selector is reduandant when all info can be added by scan
|
||||||
|
Loading…
x
Reference in New Issue
Block a user