diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index a4386800a9..ced66b2166 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -54,12 +54,14 @@ INSTALLED_APPS = [ 'company.apps.CompanyConfig', 'build.apps.BuildConfig', + # Third part add-ons 'django_filters', 'rest_framework', 'simple_history', 'crispy_forms', 'import_export', 'django_cleanup', + 'qr_code', ] MIDDLEWARE = [ diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index d2c1c13805..fc3d3f023b 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -222,6 +222,7 @@ class StockList(generics.ListCreateAPIView): filter_fields = [ 'part', + 'uuid', 'location', 'supplier_part', 'customer', diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py index 26f81ba958..cccf265605 100644 --- a/InvenTree/stock/forms.py +++ b/InvenTree/stock/forms.py @@ -38,7 +38,7 @@ class CreateStockItemForm(HelperForm): class MoveStockItemForm(forms.ModelForm): - note = forms.CharField(label='Notes', required=True) + note = forms.CharField(label='Notes', required=True, help_text='Add note (required)') class Meta: model = StockItem diff --git a/InvenTree/stock/migrations/0006_stockitem_uuid.py b/InvenTree/stock/migrations/0006_stockitem_uuid.py new file mode 100644 index 0000000000..4d358e7201 --- /dev/null +++ b/InvenTree/stock/migrations/0006_stockitem_uuid.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-04-12 15:06 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0005_stockitemtracking_quantity'), + ] + + operations = [ + migrations.AddField( + model_name='stockitem', + name='uuid', + field=models.UUIDField(blank=True, default=uuid.uuid4, editable=False), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 31c48887ba..727a211d0c 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -11,6 +11,7 @@ from django.db.models.signals import pre_delete from django.dispatch import receiver from datetime import datetime +import uuid from InvenTree.models import InvenTreeTree @@ -116,6 +117,9 @@ class StockItem(models.Model): ('part', 'serial'), ] + # UUID for generating QR codes + uuid = models.UUIDField(default=uuid.uuid4, blank=True, editable=False) + # The 'master' copy of the part of which this stock item is an instance part = models.ForeignKey('part.Part', on_delete=models.CASCADE, related_name='locations') diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 9105e78dce..f143162e7a 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -60,6 +60,7 @@ class StockItemSerializer(serializers.ModelSerializer): model = StockItem fields = [ 'pk', + 'uuid', 'url', 'part', 'supplier_part', diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index b00b77ecac..7f6673621c 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -2,6 +2,8 @@ {% load static %} {% block content %} +{% load qr_code %} +

Stock Item Details

@@ -29,11 +31,17 @@
+{% qr_from_text item.uuid size="s" image_format="png" error_correction="L" %} + + + + + {% if item.belongs_to %} diff --git a/requirements/base.txt b/requirements/base.txt index 5c0ec6f74f..03e725b7ec 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -7,4 +7,5 @@ coreapi>=2.3.0 pygments>=2.2.0 django-crispy-forms>=1.7.2 django-import-export>=1.0.0 -django-cleanup>=2.1.0 \ No newline at end of file +django-cleanup>=2.1.0 +django-qr-code==1.0.0
Part {{ item.part.name }}
UUID{{ item.uuid }}
Belongs To