mirror of
https://github.com/inventree/inventree-app.git
synced 2026-03-11 04:34:29 +00:00
Extract location data when scanning barcode (#774)
- Closes https://github.com/inventree/inventree-app/issues/772
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
## 0.xx.y - Month Year
|
||||||
|
---
|
||||||
|
|
||||||
|
- Auto-fill location data when receiving item via barcode scan
|
||||||
|
|
||||||
## 0.22.2 - February 2026
|
## 0.22.2 - February 2026
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -154,9 +154,12 @@ class POAllocateBarcodeHandler extends BarcodeHandler {
|
|||||||
return onBarcodeUnknown(data);
|
return onBarcodeUnknown(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract field data from the returned result
|
||||||
dynamic supplier_part = data["supplierpart"];
|
dynamic supplier_part = data["supplierpart"];
|
||||||
|
dynamic location = data["location"];
|
||||||
|
|
||||||
int supplier_part_pk = -1;
|
int supplier_part_pk = -1;
|
||||||
|
int location_pk = -1;
|
||||||
|
|
||||||
if (supplier_part is Map<String, dynamic>) {
|
if (supplier_part is Map<String, dynamic>) {
|
||||||
supplier_part_pk = (supplier_part["pk"] ?? -1) as int;
|
supplier_part_pk = (supplier_part["pk"] ?? -1) as int;
|
||||||
@@ -164,6 +167,10 @@ class POAllocateBarcodeHandler extends BarcodeHandler {
|
|||||||
return onBarcodeUnknown(data);
|
return onBarcodeUnknown(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (location is Map<String, dynamic>) {
|
||||||
|
location_pk = (location["pk"] ?? -1) as int;
|
||||||
|
}
|
||||||
|
|
||||||
// Dispose of the barcode scanner
|
// Dispose of the barcode scanner
|
||||||
if (OneContext.hasContext) {
|
if (OneContext.hasContext) {
|
||||||
OneContext().pop();
|
OneContext().pop();
|
||||||
@@ -177,6 +184,10 @@ class POAllocateBarcodeHandler extends BarcodeHandler {
|
|||||||
fields["part"]?["hidden"] = false;
|
fields["part"]?["hidden"] = false;
|
||||||
fields["part"]?["value"] = supplier_part_pk;
|
fields["part"]?["value"] = supplier_part_pk;
|
||||||
|
|
||||||
|
if (location_pk > 0) {
|
||||||
|
fields["location"]?["value"] = location_pk;
|
||||||
|
}
|
||||||
|
|
||||||
InvenTreePOLineItem().createForm(
|
InvenTreePOLineItem().createForm(
|
||||||
context,
|
context,
|
||||||
L10().lineItemAdd,
|
L10().lineItemAdd,
|
||||||
|
|||||||
Reference in New Issue
Block a user