Skip to content

Commit

Permalink
fix: barcode scanning for the stock entry (backport #38716) (#38718)
Browse files Browse the repository at this point in the history
fix: barcode scanning for the stock entry (#38716)

(cherry picked from commit 13cba50)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
  • Loading branch information
mergify[bot] and rohitwaghchaure authored Dec 13, 2023
1 parent feb452b commit 1dcb065
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions erpnext/public/js/controllers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
12 changes: 6 additions & 6 deletions erpnext/public/js/utils/barcode_scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion erpnext/public/js/utils/serial_no_batch_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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");
}
Expand Down
8 changes: 4 additions & 4 deletions erpnext/stock/doctype/stock_entry/stock_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 1dcb065

Please sign in to comment.