2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-05 21:20:56 +00:00

Implemented bidirectional traversal for PART and STOCK apps

- Added list view for StockItems
This commit is contained in:
Oliver
2018-04-14 15:13:16 +10:00
parent e30a089c76
commit 89ee09b01f
15 changed files with 157 additions and 38 deletions

View File

@ -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})