Extract location data when scanning barcode (#774)

- Closes https://github.com/inventree/inventree-app/issues/772
This commit is contained in:
Oliver 2026-02-22 13:57:08 +11:00 committed by GitHub
parent 91bface77f
commit 286daf2567
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View file

@ -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<String, dynamic>) {
supplier_part_pk = (supplier_part["pk"] ?? -1) as int;
@ -164,6 +167,10 @@ class POAllocateBarcodeHandler extends BarcodeHandler {
return onBarcodeUnknown(data);
}
if (location is Map<String, dynamic>) {
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,