From b64e584b52e1378c457e314fabc9249791db7e70 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 13 Apr 2019 01:12:47 +1000 Subject: [PATCH] Add UUID field to StockItem model --- .../stock/migrations/0006_stockitem_uuid.py | 19 +++++++++++++++++++ InvenTree/stock/models.py | 4 ++++ 2 files changed, 23 insertions(+) create mode 100644 InvenTree/stock/migrations/0006_stockitem_uuid.py 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')