diff --git a/assets/release_notes.md b/assets/release_notes.md index 62b42d7d..1ecdbe5c 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -1,3 +1,8 @@ +## 0.xx.y - Month Year +--- + +- Auto-fill location data when receiving item via barcode scan + ## 0.22.2 - February 2026 --- diff --git a/lib/barcode/purchase_order.dart b/lib/barcode/purchase_order.dart index 65f4913c..3e2cdbac 100644 --- a/lib/barcode/purchase_order.dart +++ b/lib/barcode/purchase_order.dart @@ -154,9 +154,12 @@ class POAllocateBarcodeHandler extends BarcodeHandler { return onBarcodeUnknown(data); } + // Extract field data from the returned result dynamic supplier_part = data["supplierpart"]; + dynamic location = data["location"]; int supplier_part_pk = -1; + int location_pk = -1; if (supplier_part is Map) { supplier_part_pk = (supplier_part["pk"] ?? -1) as int; @@ -164,6 +167,10 @@ class POAllocateBarcodeHandler extends BarcodeHandler { return onBarcodeUnknown(data); } + if (location is Map) { + location_pk = (location["pk"] ?? -1) as int; + } + // Dispose of the barcode scanner if (OneContext.hasContext) { OneContext().pop(); @@ -177,6 +184,10 @@ class POAllocateBarcodeHandler extends BarcodeHandler { fields["part"]?["hidden"] = false; fields["part"]?["value"] = supplier_part_pk; + if (location_pk > 0) { + fields["location"]?["value"] = location_pk; + } + InvenTreePOLineItem().createForm( context, L10().lineItemAdd,