mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-16 12:05:53 +00:00
[UI] Barcode actions (#9538)
* Provide callback function for barcode scan dialog
* Adds hook for barcode scan dialog
* Fix callback processing
* Add function to extract API URL for a model instance
* Tweak page titles
* Extract instance data when scanning a barcode
* Scan item into location
* Scan in stock location
* Remove notYetImplemented func
* Revert "Remove notYetImplemented func"
This reverts commit a35408380e
.
* Add stock item action
* Add playwright tests
This commit is contained in:
@ -10,7 +10,7 @@ from django.db import models
|
||||
from django.db.models import QuerySet
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.urls import reverse
|
||||
from django.urls import resolve, reverse
|
||||
from django.urls.exceptions import NoReverseMatch
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
@ -958,7 +958,17 @@ class InvenTreeBarcodeMixin(models.Model):
|
||||
|
||||
if hasattr(self, 'get_api_url'):
|
||||
api_url = self.get_api_url()
|
||||
data['api_url'] = f'{api_url}{self.pk}/'
|
||||
data['api_url'] = api_url = f'{api_url}{self.pk}/'
|
||||
|
||||
# Attempt to serialize the object too
|
||||
try:
|
||||
match = resolve(api_url)
|
||||
view_class = match.func.view_class
|
||||
serializer_class = view_class.serializer_class
|
||||
serializer = serializer_class(self)
|
||||
data['instance'] = serializer.data
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if hasattr(self, 'get_absolute_url'):
|
||||
data['web_url'] = self.get_absolute_url()
|
||||
|
Reference in New Issue
Block a user