diff --git a/InvenTree/project/models.py b/InvenTree/project/models.py index 2e228314ae..2878c87497 100644 --- a/InvenTree/project/models.py +++ b/InvenTree/project/models.py @@ -62,6 +62,7 @@ class ProjectPart(models.Model): name=self.part.name, quan=self.quantity) + class ProjectRun(models.Model): """ A single run of a particular project. Tracks the number of 'units' made in the project. diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 0e6baeb840..51e3ca2b3b 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -8,32 +8,36 @@ from InvenTree.models import InvenTreeTree class Warehouse(InvenTreeTree): pass - + class StockItem(models.Model): part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='locations') location = models.ForeignKey(Warehouse, on_delete=models.CASCADE) - quantity = models.IntegerField() + quantity = models.PositiveIntegerField() updated = models.DateField(auto_now=True) - + # Stock status types ITEM_IN_PROGRESS = 0 ITEM_INCOMING = 5 ITEM_DAMAGED = 10 ITEM_ATTENTION = 20 ITEM_COMPLETE = 50 - - status = models.IntegerField(default=ITEM_IN_PROGRESS, - choices=[ - (ITEM_IN_PROGRESS, "In progress"), - (ITEM_INCOMING, "Incoming"), - (ITEM_DAMAGED, "Damaged"), - (ITEM_ATTENTION, "Requires attention"), - (ITEM_COMPLETE, "Complete") - ]) - + + status = models.PositiveIntegerField( + default=ITEM_IN_PROGRESS, + choices=[ + (ITEM_IN_PROGRESS, "In progress"), + (ITEM_INCOMING, "Incoming"), + (ITEM_DAMAGED, "Damaged"), + (ITEM_ATTENTION, "Requires attention"), + (ITEM_COMPLETE, "Complete") + ]) + + # If stock item is incoming, an (optional) ETA field + expected_arrival = models.DateField(null=True, blank=True) + def __str__(self): return "{n} x {part} @ {loc}".format( n=self.quantity,