Hi all,
Awesome application! I've just deployed InvenTree to our little family business which was previously losing things regularly.
I'm encountering one issue with the InvenTree mobile app where the following happens when trying to scan a stock item into a location:
(The item is successfully scanned into the location, verified via the InvenTree web UI, so the error message is false).
This is my first dig into the source which I'm not familiar with, but I think the problem is in lib/barcode/stock.dart line 97, where the return statement shouldn't be inside that if block - I've added comments below:
class BarcodeScanStockItemHandler extends BarcodeHandler {
@override
String getOverlayText(BuildContext context) => L10().barcodeScanItem;
@override
Future<void> onBarcodeMatched(Map<String, dynamic> data) async {
// We expect that the barcode points to a 'stockitem'
if (data.containsKey("stockitem")) {
int _item = (data["stockitem"]["pk"] ?? -1) as int;
// A valid stock location!
if (_item > 0) {
barcodeSuccessTone();
bool result = await onItemScanned(_item);
if (result && OneContext.hasContext) {
OneContext().pop();
return; // I think this...
}
// ...should be here?
}
}
// If we get to this point, something went wrong during the scan process
barcodeFailureTone();
showSnackIcon(
L10().invalidStockItem,
success: false,
);
}
// Callback function which runs when a valid StockItem is scanned
Future<bool> onItemScanned(int itemId) async {
// Re-implement this for particular subclass
return false;
}
}
(edit: fixed indentation)
Changing the above so that the return line is moved to where I commented "should be here?" looks to resolve the issue for me. I've tested both expected success (scan a stock item into a location - now doesn't produce the false error) and expected failure (try to scan a random grocery item that InvenTree doesn't know about into a location, correctly returns "No match found for barcode data" as expected).
Am I on the right track? If yes, let me know and I'll submit a PR.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too