mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 05:25:42 +00:00
Implemented bidirectional traversal for PART and STOCK apps
- Added list view for StockItems
This commit is contained in:
@ -20,7 +20,8 @@ InvenTree
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% include "part/navbar.html" %}
|
||||
{% include "navbar.html" %}
|
||||
|
||||
{% block content %}
|
||||
<!-- Each view fills in here.. -->
|
||||
{% endblock %}
|
||||
|
@ -11,7 +11,7 @@
|
||||
{% for bom_item in part.bom_items.all %}
|
||||
{% with sub_part=bom_item.sub_part %}
|
||||
<tr>
|
||||
<td><a href="{% url 'detail' sub_part.id %}">{{ sub_part.name }}</a></td>
|
||||
<td><a href="{% url 'part-detail' sub_part.id %}">{{ sub_part.name }}</a></td>
|
||||
<td>{{ sub_part.description }}</td>
|
||||
<td>{{ bom_item.quantity }}</td>
|
||||
</tr>
|
||||
|
@ -1,7 +1,9 @@
|
||||
<div class="container">
|
||||
<a href="/part/list/">All</a> >
|
||||
<a href="/part/list/">Parts</a> >
|
||||
{% if category %}
|
||||
{% for path_item in category.parentpath %}
|
||||
<a href="/part/list/?category={{ path_item.id }}">{{ path_item.name }}</a> >
|
||||
{% endfor %}
|
||||
<a href="/part/list/?category={{ category.id }}">{{ category.name }}</a>
|
||||
{% endif %}
|
||||
</div>
|
@ -3,15 +3,15 @@
|
||||
{% block details %}
|
||||
|
||||
<br>
|
||||
<a href="{% url 'bom' part.id %}">There are <b>{{ part.bomItemCount }}</b> BOM items for this part.</a>
|
||||
<a href="{% url 'part-bom' part.id %}">There are <b>{{ part.bomItemCount }}</b> BOM items for this part.</a>
|
||||
<br>
|
||||
Used in {{ part.usedInCount }} other parts.<br>
|
||||
|
||||
<a href="{% url 'stock' part.id %}">There are {{ part.stock }} units in stock.</a>
|
||||
<a href="{% url 'part-stock' part.id %}">There are {{ part.stock }} units in stock.</a>
|
||||
|
||||
<br><br>
|
||||
{% if part.trackable %}
|
||||
<a href="{% url 'track' part.id %}">Part tracking</a>
|
||||
<a href="{% url 'part-track' part.id %}">Part tracking</a>
|
||||
{% else %}
|
||||
{{ part.name }} does not have part tracking enabled
|
||||
{% endif %}
|
||||
|
@ -2,32 +2,33 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Parts page!</h1>
|
||||
|
||||
{% if category %}
|
||||
{% include "part/cat_link.html" with category=category %}
|
||||
<h3>Child categories</h3>
|
||||
<ul>
|
||||
{% for child in category.children.all %}
|
||||
<li><a href="/part/list?category={{ child.id }}">{{ child.name }}</a></li>
|
||||
|
||||
{% if children|length > 0 %}
|
||||
<table>
|
||||
<tr>
|
||||
<th>Subcategories</th>
|
||||
</tr>
|
||||
{% for child in children %}
|
||||
<tr>
|
||||
<td><a href="/part/list/?category={{ child.id }}">{{ child.name }}</a></td>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
No category!
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
<b>Here is a list of all the parts:</b>
|
||||
|
||||
|
||||
|
||||
{% if parts|length > 0 %}
|
||||
<h3>Parts</h3>
|
||||
<table>
|
||||
{% for part in parts %}
|
||||
<tr>
|
||||
<td><a href="{% url 'detail' part.id %}">{{ part.name }}</a></td>
|
||||
<td><a href="{% url 'part-detail' part.id %}">{{ part.name }}</a></td>
|
||||
<td>{{ part.description }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
There are no parts in this category.
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
{% include "part/cat_link.html" with category=part.category %}
|
||||
|
||||
<a href="{% url 'detail' part.id %}">{{ part.name }}</a>
|
||||
<a href="{% url 'part-detail' part.id %}">{{ part.name }}</a>
|
||||
|
||||
<br>
|
||||
{{ part.description }}
|
||||
|
@ -17,7 +17,7 @@ Total in stock: {{ part.stock }}
|
||||
{% for stock in part.locations.all %}
|
||||
<tr>
|
||||
<td>{{ stock.quantity }}</td>
|
||||
<td>{{ stock.location.name }}</td>
|
||||
<td><a href="/stock/list/?location={{ stock.location.id }}">{{ stock.location.name }}</a></td>
|
||||
<td>
|
||||
{% if stock.supplier_part %}
|
||||
{{ stock.supplier_part.supplier.name }} | {{ stock.supplier_part.SKU }}
|
||||
|
@ -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<pk>\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'),
|
||||
]
|
||||
|
||||
|
||||
|
@ -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))
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user