More tab updates

- Add Stock tab
- Add Stock table for supplier part
- Allow stock API to be filtered by supplier-part ID
- Add Orders tab
This commit is contained in:
Oliver Walters 2020-02-12 11:09:37 +11:00
parent d9d21395d9
commit 8dd8505a2c
7 changed files with 68 additions and 9 deletions

View File

@ -35,9 +35,6 @@
{% endif %}
</table>
<h4>{% trans "Purchase Orders" %}</h4>
{% include "order/po_table.html" with orders=part.purchase_orders %}
{% endblock %}
{% block js_ready %}

View File

@ -0,0 +1,19 @@
{% extends "company/supplier_part_base.html" %}
{% load static %}
{% load i18n %}
{% block details %}
{% include "company/supplier_part_tabs.html" with tab='orders' %}
<hr>
<h4>{% trans "Supplier Part Orders" %}</h4>
{% include "order/po_table.html" with orders=part.purchase_orders %}
{% endblock %}
{% block js_ready %}
{{ block.super }}
{% endblock %}

View File

@ -7,6 +7,7 @@
{% include "company/supplier_part_tabs.html" with tab='pricing' %}
<hr>
<h4>{% trans "Pricing Information" %}</h4>
<table class="table table-striped table-condensed">

View File

@ -0,0 +1,36 @@
{% extends "company/supplier_part_base.html" %}
{% load static %}
{% load i18n %}
{% block details %}
{% include "company/supplier_part_tabs.html" with tab='stock' %}
<hr>
<h4>{% trans "Supplier Part Stock" %}</h4>
{% include "stock_table.html" %}
{% endblock %}
{% block js_load %}
{{ block.super }}
<script type='text/javascript' src="{% static 'script/inventree/stock.js' %}"></script>
{% endblock %}
{% block js_ready %}
{{ block.super }}
loadStockTable($("#stock-table"), {
params: {
supplier_part: {{ part.id }},
location_detail: true,
part_detail: true,
},
groupByField: 'location',
buttons: ['#stock-options'],
url: "{% url 'api-stock-list' %}",
});
{% endblock %}

View File

@ -8,12 +8,9 @@
<a href="{% url 'supplier-part-pricing' part.id %}">{% trans "Pricing" %}</a>
</li>
<li{% if tab == 'stock' %} class='active'{% endif %}>
<a href="{% url 'supplier-part-detail' part.id %}">{% trans "Stock" %}</a>
<a href="{% url 'supplier-part-stock' part.id %}">{% trans "Stock" %}</a>
</li>
<li {% if tab == 'orders' %} class='active'{% endif %}>
<a href="{% url 'supplier-part-detail' part.id %}">{% trans "Orders" %}</a>
</li>
<li {% if tab == 'notes' %} class='active'{% endif %}>
<a href="{% url 'supplier-part-detail' part.id %}">{% trans "Notes" %}</a>
<a href="{% url 'supplier-part-orders' part.id %}">{% trans "Orders" %}</a>
</li>
</ul>

View File

@ -50,6 +50,8 @@ supplier_part_detail_urls = [
url(r'^edit/?', views.SupplierPartEdit.as_view(), name='supplier-part-edit'),
url(r'^pricing/', views.SupplierPartDetail.as_view(template_name='company/supplier_part_pricing.html'), name='supplier-part-pricing'),
url(r'^orders/', views.SupplierPartDetail.as_view(template_name='company/supplier_part_orders.html'), name='supplier-part-orders'),
url(r'^stock/', views.SupplierPartDetail.as_view(template_name='company/supplier_part_stock.html'), name='supplier-part-stock'),
url('^.*$', views.SupplierPartDetail.as_view(), name='supplier-part-detail'),
]

View File

@ -301,6 +301,7 @@ class StockList(generics.ListCreateAPIView):
'part__category',
'part__category__name',
'part__category__description',
'supplier_part',
)
# Reduce the number of lookups we need to do for categories
@ -371,7 +372,13 @@ class StockList(generics.ListCreateAPIView):
except PartCategory.DoesNotExist:
pass
# Filter by supplier
# Filter by supplier_part ID
supplier_part_id = self.request.query_params.get('supplier_part', None)
if supplier_part_id:
stock_list = stock_list.filter(supplier_part=supplier_part_id)
# Filter by supplier ID
supplier_id = self.request.query_params.get('supplier', None)
if supplier_id: