Added stock status field

This commit is contained in:
Oliver Walters 2017-03-28 22:27:46 +11:00
parent 7bcea2f3ac
commit deda73a50f
4 changed files with 17 additions and 3 deletions

View File

@ -4,7 +4,7 @@ from .models import PartCategory, Part
class PartAdmin(admin.ModelAdmin):
list_display = ('name', 'IPN', 'quantity', 'category')
list_display = ('name', 'IPN', 'stock', 'category')
# Custom form for PartCategory
class PartCategoryAdmin(admin.ModelAdmin):

View File

@ -45,7 +45,7 @@ class Part(models.Model):
return self.stockitem_set.all()
@property
def quantity(self):
def stock(self):
""" Return the total stock quantity for this part.
Part may be stored in multiple locations
"""

View File

@ -6,7 +6,7 @@ class WarehouseAdmin(admin.ModelAdmin):
list_display = ('name', 'path', 'description')
class StockItemAdmin(admin.ModelAdmin):
list_display = ('part', 'quantity', 'location', 'updated')
list_display = ('part', 'quantity', 'location', 'status', 'updated')
admin.site.register(Warehouse, WarehouseAdmin)
admin.site.register(StockItem, StockItemAdmin)

View File

@ -15,6 +15,20 @@ class StockItem(models.Model):
quantity = models.IntegerField()
updated = models.DateField(auto_now=True)
# Stock status types
ITEM_IN_PROGRESS = 0
ITEM_DAMAGED = 10
ITEM_RETURNED = 20
ITEM_COMPLETE = 50
status = models.IntegerField(default=ITEM_IN_PROGRESS,
choices=[
(ITEM_IN_PROGRESS, "In progress"),
(ITEM_DAMAGED, "Damaged"),
(ITEM_RETURNED, "Returned"),
(ITEM_COMPLETE, "Complete")
])
def __str__(self):
return "{n} x {part} @ {loc}".format(
n = self.quantity,