From 1dcb065c64ba5c04323f25300b13cbce697d5e63 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 13 Dec 2023 18:32:48 +0530 Subject: [PATCH] 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 --- erpnext/public/js/controllers/transaction.js | 1 + erpnext/public/js/utils/barcode_scanner.js | 12 ++++++------ erpnext/public/js/utils/serial_no_batch_selector.js | 5 ++++- erpnext/stock/doctype/stock_entry/stock_entry.js | 8 ++++---- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index c1c4b99dca..de65cc5dfe 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -380,6 +380,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } scan_barcode() { + frappe.flags.dialog_set = false; const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm}); barcode_scanner.process_scan(); } diff --git a/erpnext/public/js/utils/barcode_scanner.js b/erpnext/public/js/utils/barcode_scanner.js index a4f74bdaee..a1ebfe9aa4 100644 --- a/erpnext/public/js/utils/barcode_scanner.js +++ b/erpnext/public/js/utils/barcode_scanner.js @@ -114,13 +114,13 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { frappe.run_serially([ () => 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.show_scan_message(row.idx, row.item_code, qty); }), () => 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.revert_selector_flag(), () => 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 // this flag on item row is used by transaction.js to avoid triggering selector 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_serial = has_serial_no && !serial_no; + const require_selecting_batch = has_batch_no; + const require_selecting_serial = has_serial_no; if (!(require_selecting_batch || require_selecting_serial)) { frappe.flags.hide_serial_batch_dialog = true; diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js index 3b9a551b43..7b9cdfef2a 100644 --- a/erpnext/public/js/utils/serial_no_batch_selector.js +++ b/erpnext/public/js/utils/serial_no_batch_selector.js @@ -31,6 +31,8 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { secondary_action: () => this.edit_full_form(), }); + this.dialog.show(); + let qty = this.item.stock_qty || this.item.transfer_qty || this.item.qty; this.dialog.set_value("qty", qty).then(() => { if (this.item.serial_no) { @@ -40,9 +42,10 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { this.dialog.set_value("scan_batch_no", this.item.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.css("display", "inline"); } diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 7334b356ee..7af5d1aa37 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -781,10 +781,9 @@ frappe.ui.form.on('Stock Entry Detail', { }); refresh_field("items"); - let no_batch_serial_number_value = !d.serial_no; - if (d.has_batch_no && !d.has_serial_no) { - // check only batch_no for batched item - no_batch_serial_number_value = !d.batch_no; + let no_batch_serial_number_value = false; + if (d.has_serial_no || d.has_batch_no) { + no_batch_serial_number_value = true; } 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() { + frappe.flags.dialog_set = false; const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm}); barcode_scanner.process_scan(); }