Barcode Scanner: "Scan barcode for item" dialog silently discards unknown or mismatched Serial Nos · Issue #61763 · frappe/erpnext · GitHub
Skip to content

Barcode Scanner: "Scan barcode for item" dialog silently discards unknown or mismatched Serial Nos #61763

Closed

Description

@karantarale-tech

Information about bug

When a Delivery Note has items (e.g. created from a Sales Order), scanning an item barcode on the Scan Barcode field opens the "Scan barcode for item {item_code}" dialog from erpnext.utils.BarcodeScanner.prepare_item_for_scan. The operator then scans Serial Nos into that dialog one by one.

If a scanned value does not resolve to a Serial No of the dialog's item, the dialog clears the input and does nothing else. No message is shown, Scanned Quantity does not change, and no error sound plays. This happens when the Serial No does not exist, and also when it exists but belongs to a different item. With a handheld scanner the operator usually does not look at the screen after each scan, so the rejected scan goes unnoticed until the counts do not match.

The same dialog already shows an Error message box for a duplicate scan ("Serial No {0} already scanned", from validate_duplicate_serial_no), and the main Scan Barcode field shows a red "Cannot find Item with this Barcode" alert for an unknown code. Only the dialog's unknown/mismatched path is silent.

The cause is in update_dialog_values in erpnext/public/js/utils/barcode_scanner.js. It clears barcode_scanner and then only acts when item_code === scanned_item. There is no else branch. When scan_barcode finds nothing it returns {}, which is truthy, so update_dialog_values is called, the item_code check fails, and the scan is dropped without feedback.

Steps to reproduce

  1. Create a serialised item with an Item Barcode, and a few Serial Nos for it in a warehouse.
  2. Create a Sales Order for 10 of the item and make a Delivery Note from it.
  3. On the Delivery Note, scan the item's barcode in Scan Barcode. The "Scan barcode for item {item_code}" dialog opens.
  4. Scan a valid Serial No. It is added and Scanned Quantity goes to 1.
  5. Scan the same Serial No again. An Error box shows "Serial No {0} already scanned".
  6. Scan a value that is not an existing Serial No (e.g. S999999).
  7. Scan an existing Serial No of a different item.

Observed result

  • Steps 6 and 7: the input clears, Serial Nos and Scanned Quantity do not change, and nothing tells the operator that the scan was rejected.

Expected result

  • Steps 6 and 7 show an Error message in the same way as the duplicate scan, for example "Serial No {0} not found" and "Serial No {0} belongs to Item {1}, not {2}", and play the fail sound if one is configured.

Additional context

The scan field's own path (process_scan) already handles an empty result with an alert and play_fail_sound(), so the dialog path could follow the same pattern. scan_barcode returns a Serial No by name without checking its status or warehouse, so a Delivered or Inactive Serial No is accepted by the dialog and only rejected later on submit. That may be worth a separate check in the same place.

Module

stock

Version

ERPNext: v16.51.1
Frappe Framework: v16.52.0

Installation method

None

Relevant log output / Stack trace / Full Error Message.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions