From ce854e31199f88a0be5d5a91d3c9579c7dda69cd Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 14 Apr 2018 15:26:42 +1000 Subject: [PATCH] Add 'detail' view for stock item --- InvenTree/stock/models.py | 5 +++++ InvenTree/stock/templates/stock/detail.html | 21 +++++++++++++++++++++ InvenTree/stock/templates/stock/index.html | 2 ++ InvenTree/stock/views.py | 4 ++-- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 InvenTree/stock/templates/stock/detail.html diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 005b6aa44a..f89837b7a0 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -26,13 +26,18 @@ class StockLocation(InvenTreeTree): class StockItem(models.Model): part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='locations') + supplier_part = models.ForeignKey(SupplierPart, blank=True, null=True, on_delete=models.SET_NULL) + location = models.ForeignKey(StockLocation, on_delete=models.CASCADE) + quantity = models.PositiveIntegerField(validators=[MinValueValidator(0)]) + updated = models.DateField(auto_now=True) # last time the stock was checked / counted stocktake_date = models.DateField(blank=True, null=True) + stocktake_user = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True) review_needed = models.BooleanField(default=False) diff --git a/InvenTree/stock/templates/stock/detail.html b/InvenTree/stock/templates/stock/detail.html new file mode 100644 index 0000000000..e9b758c8d2 --- /dev/null +++ b/InvenTree/stock/templates/stock/detail.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} + +{% block content %} + +{% include "stock/loc_link.html" with location=item.location %} + + + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/index.html b/InvenTree/stock/templates/stock/index.html index d751588c55..fe6809f0f3 100644 --- a/InvenTree/stock/templates/stock/index.html +++ b/InvenTree/stock/templates/stock/index.html @@ -18,6 +18,7 @@ {% if items|length > 0 %} + @@ -25,6 +26,7 @@ {% for item in items %} + diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 32e47f2830..64dd293b84 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -38,6 +38,6 @@ def index(request): def detail(request, pk): - item = get_object_or_404(Stock, pk=pk) + stock = get_object_or_404(StockItem, pk=pk) - return render(request, 'stock/detail.html', {'item' : item}) \ No newline at end of file + return render(request, 'stock/detail.html', {'item' : stock}) \ No newline at end of file
Item Part Stock Stocktake
Click here {{ item.part.name }} {{ item.quantity }} {{ item.stocktake_date }}