diff --git a/InvenTree/stock/migrations/0005_stockitemtracking_quantity.py b/InvenTree/stock/migrations/0005_stockitemtracking_quantity.py new file mode 100644 index 0000000000..f654486075 --- /dev/null +++ b/InvenTree/stock/migrations/0005_stockitemtracking_quantity.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-04-12 14:09 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0004_auto_20190412_2030'), + ] + + operations = [ + migrations.AddField( + model_name='stockitemtracking', + name='quantity', + field=models.PositiveIntegerField(default=1, validators=[django.core.validators.MinValueValidator(0)]), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index a3bbbcff74..31c48887ba 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -209,6 +209,7 @@ class StockItem(models.Model): item=self, title=title, user=user, + quantity=self.quantity, date=datetime.now().date(), notes=notes, system=system @@ -346,6 +347,9 @@ class StockItemTracking(models.Model): # Was this tracking note auto-generated by the system? system = models.BooleanField(default=False) + # Keep track of the StockItem quantity throughout the tracking history + quantity = models.PositiveIntegerField(validators=[MinValueValidator(0)], default=1) + # TODO # image = models.ImageField(upload_to=func, max_length=255, null=True, blank=True) diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 6479e4aa88..9105e78dce 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -35,6 +35,7 @@ class StockTrackingSerializer(serializers.ModelSerializer): 'date', 'title', 'notes', + 'quantity', 'user', 'system', ] @@ -43,6 +44,7 @@ class StockTrackingSerializer(serializers.ModelSerializer): 'date', 'user', 'system', + 'quantity', ] diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 06250c448e..b00b77ecac 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -215,6 +215,10 @@ return html; } }, + { + field: 'quantity', + title: 'Quantity', + }, { sortable: true, field: 'user',