From f70bde02d2378280e7785002d9ebb4cfd23c0a7b Mon Sep 17 00:00:00 2001 From: Oliver <oliver.henry.walters@gmail.com> Date: Tue, 11 Apr 2023 14:06:02 +1000 Subject: [PATCH] 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 --- InvenTree/plugin/builtin/barcodes/inventree_barcode.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/InvenTree/plugin/builtin/barcodes/inventree_barcode.py b/InvenTree/plugin/builtin/barcodes/inventree_barcode.py index 330c2e8fca..5d1d016139 100644 --- a/InvenTree/plugin/builtin/barcodes/inventree_barcode.py +++ b/InvenTree/plugin/builtin/barcodes/inventree_barcode.py @@ -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