mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-04 01:15:20 +00:00
Fixes for barcode decoding
This commit is contained in:
1 parent
a4267f76e8
commit
ccda637e3c
1 file changed
+22
-1
@@ -68,7 +68,7 @@ class InvenTreeBarcodePlugin(BarcodePlugin):
|
|||||||
# Initially try casting to an integer
|
# Initially try casting to an integer
|
||||||
try:
|
try:
|
||||||
pk = int(data)
|
pk = int(data)
|
||||||
except (ValueError):
|
except (TypeError, ValueError):
|
||||||
pk = None
|
pk = None
|
||||||
|
|
||||||
if pk is None:
|
if pk is None:
|
||||||
@@ -89,6 +89,17 @@ class InvenTreeBarcodePlugin(BarcodePlugin):
|
|||||||
|
|
||||||
for k in self.data.keys():
|
for k in self.data.keys():
|
||||||
if k.lower() == 'stocklocation':
|
if k.lower() == 'stocklocation':
|
||||||
|
|
||||||
|
pk = None
|
||||||
|
|
||||||
|
# First try simple integer lookup
|
||||||
|
try:
|
||||||
|
pk = int(self.data[k])
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
pk = None
|
||||||
|
|
||||||
|
if pk is None:
|
||||||
|
# Lookup by 'id' field
|
||||||
try:
|
try:
|
||||||
pk = self.data[k]['id']
|
pk = self.data[k]['id']
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
@@ -106,6 +117,16 @@ class InvenTreeBarcodePlugin(BarcodePlugin):
|
|||||||
|
|
||||||
for k in self.data.keys():
|
for k in self.data.keys():
|
||||||
if k.lower() == 'part':
|
if k.lower() == 'part':
|
||||||
|
|
||||||
|
pk = None
|
||||||
|
|
||||||
|
# Try integer lookup first
|
||||||
|
try:
|
||||||
|
pk = int(self.data[k])
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
pk = None
|
||||||
|
|
||||||
|
if pk is None:
|
||||||
try:
|
try:
|
||||||
pk = self.data[k]['id']
|
pk = self.data[k]['id']
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
|
|||||||
Reference in new issue
Block a user