mirror of
https://github.com/inventree/inventree-app.git
synced 2026-03-11 12:45:00 +00:00
Extract location data when scanning barcode (#774)
- Closes https://github.com/inventree/inventree-app/issues/772
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user