mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-11 15:34:15 +00:00
Barcode scan fix (#3727)
* Fix barcode scanning in web interface * Improve error handling for barcode scan dialog * JS linting
This commit is contained in:
@ -34,19 +34,29 @@ class InvenTreeBarcodePlugin(BarcodeMixin, InvenTreePlugin):
|
||||
def format_matched_response(self, label, model, instance):
|
||||
"""Format a response for the scanned data"""
|
||||
|
||||
response = {
|
||||
data = {
|
||||
'pk': instance.pk
|
||||
}
|
||||
|
||||
# Add in the API URL if available
|
||||
if hasattr(model, 'get_api_url'):
|
||||
response['api_url'] = f"{model.get_api_url()}{instance.pk}/"
|
||||
data['api_url'] = f"{model.get_api_url()}{instance.pk}/"
|
||||
|
||||
# Add in the web URL if available
|
||||
if hasattr(instance, 'get_absolute_url'):
|
||||
response['web_url'] = instance.get_absolute_url()
|
||||
url = instance.get_absolute_url()
|
||||
data['web_url'] = url
|
||||
else:
|
||||
url = None
|
||||
|
||||
response = {
|
||||
label: data
|
||||
}
|
||||
|
||||
if url is not None:
|
||||
response['url'] = url
|
||||
|
||||
return {label: response}
|
||||
return response
|
||||
|
||||
|
||||
class InvenTreeInternalBarcodePlugin(InvenTreeBarcodePlugin):
|
||||
|
Reference in New Issue
Block a user