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 2023-04-11 14:06:02 +10:00 committed by GitHub
parent 46cd109359
commit f70bde02d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,7 +100,8 @@ class InvenTreeInternalBarcodePlugin(BarcodeMixin, InvenTreePlugin):
if label in barcode_dict: if label in barcode_dict:
try: 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) return self.format_matched_response(label, model, instance)
except (ValueError, model.DoesNotExist): except (ValueError, model.DoesNotExist):
pass pass