Add quantity field to StockItemTracking

- Keep track of historical levels of part availability
This commit is contained in:
Oliver Walters 2019-04-13 00:14:10 +10:00
parent 93bb0bf6f4
commit 926d717190
4 changed files with 29 additions and 0 deletions

View File

@ -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)]),
),
]

View File

@ -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)

View File

@ -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',
]

View File

@ -215,6 +215,10 @@
return html;
}
},
{
field: 'quantity',
title: 'Quantity',
},
{
sortable: true,
field: 'user',