{{ stock.quantity }} |
- {{ stock.location.name }} |
+ {{ stock.location.name }} |
{% if stock.supplier_part %}
{{ stock.supplier_part.supplier.name }} | {{ stock.supplier_part.SKU }}
diff --git a/InvenTree/part/urls.py b/InvenTree/part/urls.py
index 5abe293ffc..5943401302 100644
--- a/InvenTree/part/urls.py
+++ b/InvenTree/part/urls.py
@@ -39,10 +39,10 @@ bom_api_urls = [
]
part_detail_urls = [
- url(r'^track/?', views.track, name='track'),
- url(r'^bom/?', views.bom, name='bom'),
- url(r'^stock/?', views.stock, name='stock'),
- url('', views.detail, name='detail'),
+ url(r'^track/?', views.track, name='part-track'),
+ url(r'^bom/?', views.bom, name='part-bom'),
+ url(r'^stock/?', views.stock, name='part-stock'),
+ url('', views.detail, name='part-detail'),
]
# URL list for part web interface
@@ -50,10 +50,10 @@ part_urls = [
# Individual
url(r'^(?P\d+)/', include(part_detail_urls)),
- url('list', views.index, name='index'),
+ url('list', views.index, name='part-index'),
# ex: /part/5/
- url(r'^.*$', RedirectView.as_view(url='list', permanent=False), name='index'),
+ url(r'^.*$', RedirectView.as_view(url='list', permanent=False), name='part-index'),
]
diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py
index c93d52bc00..47eea2608a 100644
--- a/InvenTree/part/views.py
+++ b/InvenTree/part/views.py
@@ -22,16 +22,20 @@ def index(request):
cat_id = request.GET['category']
cat = get_object_or_404(PartCategory, pk=cat_id)
- #cat = PartCategory.objects.get(pk=cat_id)
+
parts = parts.filter(category = cat_id)
+ children = PartCategory.objects.filter(parent = cat_id)
+
+ else:
+ parts = parts.filter(category__isnull=True)
+ children = PartCategory.objects.filter(parent__isnull=True)
context = {
'parts' : parts.order_by('category__name'),
+ 'category' : cat,
+ 'children' : children,
}
- if cat:
- context['category'] = cat
-
return HttpResponse(template.render(context, request))
diff --git a/InvenTree/stock/templates/stock/index.html b/InvenTree/stock/templates/stock/index.html
new file mode 100644
index 0000000000..d751588c55
--- /dev/null
+++ b/InvenTree/stock/templates/stock/index.html
@@ -0,0 +1,38 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+{% include "stock/loc_link.html" with location=location %}
+
+{% if children|length > 0 %}
+
+ Sublocations |
+{% for child in children %}
+
+ {{ child.name }} |
+
+{% endfor %}
+
+{% endif %}
+
+{% if items|length > 0 %}
+
+
+ Part |
+ Stock |
+ Stocktake |
+ Notes |
+
+{% for item in items %}
+
+ {{ item.part.name }} |
+ {{ item.quantity }} |
+ {{ item.stocktake_date }} |
+ {{ item.notes }} |
+
+{% endfor %}
+
+{% else %}
+There are no parts in this location.
+{% endif %}
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/stock/templates/stock/loc_link.html b/InvenTree/stock/templates/stock/loc_link.html
new file mode 100644
index 0000000000..9c2db9b9c7
--- /dev/null
+++ b/InvenTree/stock/templates/stock/loc_link.html
@@ -0,0 +1,9 @@
+
\ No newline at end of file
diff --git a/InvenTree/stock/urls.py b/InvenTree/stock/urls.py
index 0ca312ebfc..911fa306c9 100644
--- a/InvenTree/stock/urls.py
+++ b/InvenTree/stock/urls.py
@@ -1,4 +1,5 @@
from django.conf.urls import url, include
+from django.views.generic.base import RedirectView
from . import views
from . import api
@@ -11,7 +12,7 @@ stock_endpoints = [
url(r'^add-stock/?$', api.AddStockEndpoint.as_view(), name='stockitem-add-stock'),
]
-stock_urls = [
+stock_api_urls = [
# Detail for a single stock item
url(r'^(?P[0-9]+)/', include(stock_endpoints)),
@@ -20,10 +21,25 @@ stock_urls = [
url(r'^$', api.StockList.as_view()),
]
-stock_loc_urls = [
+stock_api_loc_urls = [
url(r'^(?P[0-9]+)/?$', api.LocationDetail.as_view(), name='stocklocation-detail'),
url(r'^\?.*/?$', api.LocationList.as_view()),
url(r'^$', api.LocationList.as_view())
]
+
+
+# URL list for web interface
+stock_detail_urls = [
+ url('', views.detail, name='stock-detail'),
+]
+stock_urls = [
+ # Individual stock items
+ url(r'^(?P\d+)/', include(stock_detail_urls)),
+
+ url('list', views.index, name='stock=index'),
+
+ # Redirect any other patterns
+ url(r'^.*$', RedirectView.as_view(url='list', permanent=False), name='stock-index'),
+]
\ No newline at end of file
diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py
index e69de29bb2..32e47f2830 100644
--- a/InvenTree/stock/views.py
+++ b/InvenTree/stock/views.py
@@ -0,0 +1,43 @@
+from django.http import HttpResponse
+from django.template import loader
+
+from django.shortcuts import get_object_or_404, render
+
+from .models import StockItem, StockLocation
+
+def index(request):
+ template = loader.get_template('stock/index.html')
+
+ items = StockItem.objects.all()
+
+ location = None
+
+ if 'location' in request.GET:
+ loc_id = request.GET['location']
+
+ location = get_object_or_404(StockLocation, pk=loc_id)
+
+ items = items.filter(location = loc_id)
+
+ children = StockLocation.objects.filter(parent = loc_id)
+
+ else:
+ # No stock items can exist without a location
+ items = None
+ location = None
+ children = StockLocation.objects.filter(parent__isnull=True)
+
+ context = {
+ 'items' : items,
+ 'location' : location,
+ 'children' : children,
+ }
+
+ return HttpResponse(template.render(context, request))
+
+
+def detail(request, pk):
+
+ item = get_object_or_404(Stock, pk=pk)
+
+ return render(request, 'stock/detail.html', {'item' : item})
\ No newline at end of file
|