Fix for scanning invalid barcode (#4597)

- Cast PK to integer first, so we get a value error thrown
- Prevents other errors (such as TypeError) from throwing
This commit is contained in:
Oliver authored and GitHub committed 2023-04-11 14:06:02 +10:00
1 parent 46cd109359
commit f70bde02d2
1 file changed
+2 -1
@@ -100,7 +100,8 @@ class InvenTreeInternalBarcodePlugin(BarcodeMixin, InvenTreePlugin):
if label in barcode_dict:
try:
instance = model.objects.get(pk=barcode_dict[label])
pk = int(barcode_dict[label])
instance = model.objects.get(pk=pk)
return self.format_matched_response(label, model, instance)
except (ValueError, model.DoesNotExist):
pass