fix: barcode scanning for the stock entry (backport #38716) (#38718)

fix: barcode scanning for the stock entry (#38716)

(cherry picked from commit 13cba5068bd1d09bff4204a64a74999876566b6b)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot] 2023-12-13 18:32:48 +05:30 committed by GitHub
parent feb452b740
commit 1dcb065c64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 11 deletions

View File

@ -380,6 +380,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
scan_barcode() { scan_barcode() {
frappe.flags.dialog_set = false;
const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm}); const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm});
barcode_scanner.process_scan(); barcode_scanner.process_scan();
} }

View File

@ -114,13 +114,13 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
frappe.run_serially([ frappe.run_serially([
() => this.set_selector_trigger_flag(data), () => this.set_selector_trigger_flag(data),
() => this.set_serial_no(row, serial_no),
() => this.set_batch_no(row, batch_no),
() => this.set_barcode(row, barcode),
() => this.set_item(row, item_code, barcode, batch_no, serial_no).then(qty => { () => this.set_item(row, item_code, barcode, batch_no, serial_no).then(qty => {
this.show_scan_message(row.idx, row.item_code, qty); this.show_scan_message(row.idx, row.item_code, qty);
}), }),
() => this.set_barcode_uom(row, uom), () => this.set_barcode_uom(row, uom),
() => this.set_serial_no(row, serial_no),
() => this.set_batch_no(row, batch_no),
() => this.set_barcode(row, barcode),
() => this.clean_up(), () => this.clean_up(),
() => this.revert_selector_flag(), () => this.revert_selector_flag(),
() => resolve(row) () => resolve(row)
@ -131,10 +131,10 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
// 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
// this flag on item row is used by transaction.js to avoid triggering selector // this flag on item row is used by transaction.js to avoid triggering selector
set_selector_trigger_flag(data) { set_selector_trigger_flag(data) {
const {batch_no, serial_no, has_batch_no, has_serial_no} = data; const {has_batch_no, has_serial_no} = data;
const require_selecting_batch = has_batch_no && !batch_no; const require_selecting_batch = has_batch_no;
const require_selecting_serial = has_serial_no && !serial_no; const require_selecting_serial = has_serial_no;
if (!(require_selecting_batch || require_selecting_serial)) { if (!(require_selecting_batch || require_selecting_serial)) {
frappe.flags.hide_serial_batch_dialog = true; frappe.flags.hide_serial_batch_dialog = true;

View File

@ -31,6 +31,8 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
secondary_action: () => this.edit_full_form(), secondary_action: () => this.edit_full_form(),
}); });
this.dialog.show();
let qty = this.item.stock_qty || this.item.transfer_qty || this.item.qty; let qty = this.item.stock_qty || this.item.transfer_qty || this.item.qty;
this.dialog.set_value("qty", qty).then(() => { this.dialog.set_value("qty", qty).then(() => {
if (this.item.serial_no) { if (this.item.serial_no) {
@ -40,9 +42,10 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
this.dialog.set_value("scan_batch_no", this.item.batch_no); this.dialog.set_value("scan_batch_no", this.item.batch_no);
frappe.model.set_value(this.item.doctype, this.item.name, 'batch_no', ''); frappe.model.set_value(this.item.doctype, this.item.name, 'batch_no', '');
} }
this.dialog.fields_dict.entries.grid.refresh();
}); });
this.dialog.show();
this.$scan_btn = this.dialog.$wrapper.find(".link-btn"); this.$scan_btn = this.dialog.$wrapper.find(".link-btn");
this.$scan_btn.css("display", "inline"); this.$scan_btn.css("display", "inline");
} }

View File

@ -781,10 +781,9 @@ frappe.ui.form.on('Stock Entry Detail', {
}); });
refresh_field("items"); refresh_field("items");
let no_batch_serial_number_value = !d.serial_no; let no_batch_serial_number_value = false;
if (d.has_batch_no && !d.has_serial_no) { if (d.has_serial_no || d.has_batch_no) {
// check only batch_no for batched item no_batch_serial_number_value = true;
no_batch_serial_number_value = !d.batch_no;
} }
if (no_batch_serial_number_value && !frappe.flags.hide_serial_batch_dialog && !frappe.flags.dialog_set) { if (no_batch_serial_number_value && !frappe.flags.hide_serial_batch_dialog && !frappe.flags.dialog_set) {
@ -941,6 +940,7 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle
} }
scan_barcode() { scan_barcode() {
frappe.flags.dialog_set = false;
const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm}); const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm});
barcode_scanner.process_scan(); barcode_scanner.process_scan();
} }