mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-05 21:20:56 +00:00
QR code improvements
- Display QR codes as links to served images - The qr_code plugin caches these images in the background - Make a qr_code template to push out as a modal form - Create a QRCodeView to simplify display of QR codes - Add option to launchModalForm() to disable the 'submit' button Refactored QR code display for - StockLocation - StockItem - Part
This commit is contained in:
@ -10,6 +10,7 @@ from django.forms.models import model_to_dict
|
||||
from django.forms import HiddenInput
|
||||
|
||||
from InvenTree.views import AjaxUpdateView, AjaxDeleteView, AjaxCreateView
|
||||
from InvenTree.views import QRCodeView
|
||||
|
||||
from part.models import Part
|
||||
from .models import StockItem, StockLocation, StockItemTracking
|
||||
@ -75,6 +76,34 @@ class StockLocationEdit(AjaxUpdateView):
|
||||
ajax_form_title = 'Edit Stock Location'
|
||||
|
||||
|
||||
class StockLocationQRCode(QRCodeView):
|
||||
""" View for displaying a QR code for a StockLocation object """
|
||||
|
||||
ajax_form_title = "Stock Location QR code"
|
||||
|
||||
def get_qr_data(self):
|
||||
""" Generate QR code data for the StockLocation """
|
||||
try:
|
||||
loc = StockLocation.objects.get(id=self.pk)
|
||||
return loc.format_barcode()
|
||||
except StockLocation.DoesNotExist:
|
||||
return None
|
||||
|
||||
|
||||
class StockItemQRCode(QRCodeView):
|
||||
""" View for displaying a QR code for a StockItem object """
|
||||
|
||||
ajax_form_title = "Stock Item QR Code"
|
||||
|
||||
def get_qr_data(self):
|
||||
""" Generate QR code data for the StockItem """
|
||||
try:
|
||||
item = StockItem.objects.get(id=self.pk)
|
||||
return item.format_barcode()
|
||||
except StockItem.DoesNotExist:
|
||||
return None
|
||||
|
||||
|
||||
class StockItemEdit(AjaxUpdateView):
|
||||
"""
|
||||
View for editing details of a single StockItem
|
||||
|
Reference in New Issue
Block a user