mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Push even more barcode decoding to the individual plugin
- DigiKey barcode is NOT json formatted, for example...
This commit is contained in:
@ -11,6 +11,8 @@ references model objects actually exist in the database.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
|
||||
from . import barcode
|
||||
|
||||
from stock.models import StockItem, StockLocation
|
||||
@ -34,6 +36,17 @@ class InvenTreeBarcodePlugin(barcode.BarcodePlugin):
|
||||
|
||||
"""
|
||||
|
||||
# The data must either be dict or be able to dictified
|
||||
if type(self.data) is dict:
|
||||
pass
|
||||
elif type(self.data) is str:
|
||||
try:
|
||||
self.data = json.loads(self.data)
|
||||
except json.JSONDecodeError:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
for key in ['tool', 'version']:
|
||||
if key not in self.data.keys():
|
||||
return False
|
||||
|
Reference in New Issue
Block a user