diff --git a/InvenTree/stock/admin.py b/InvenTree/stock/admin.py index 99d70ff9f4..a3e5c188f4 100644 --- a/InvenTree/stock/admin.py +++ b/InvenTree/stock/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from simple_history.admin import SimpleHistoryAdmin from .models import StockLocation, StockItem - +from .models import StockItemTracking class LocationAdmin(admin.ModelAdmin): list_display = ('name', 'pathstring', 'description') @@ -12,5 +12,9 @@ class StockItemAdmin(SimpleHistoryAdmin): list_display = ('part', 'quantity', 'location', 'status', 'updated') +class StockTrackingAdmin(admin.ModelAdmin): + list_display = ('item', 'date', 'title') + admin.site.register(StockLocation, LocationAdmin) admin.site.register(StockItem, StockItemAdmin) +admin.site.register(StockItemTracking, StockTrackingAdmin) \ No newline at end of file diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index d6bd3ba867..689a04523c 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -121,6 +121,10 @@ class StockItem(models.Model): infinite = models.BooleanField(default=False) + @property + def has_tracking_info(self): + return self.tracking_info.all().count() > 0 + @transaction.atomic def stocktake(self, count, user): """ Perform item stocktake. diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index c7955f0d7f..7266e692f4 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -72,6 +72,21 @@ {% endif %} +{% if item.has_tracking_info %} +

Stock Tracking

+ +{% endif %} +