Display table of items received against a particular purchase order

- Adds new tab to "Purchase Order" view
- Adds ability to filter StockList API by purchase_order ID
This commit is contained in:
Oliver Walters 2020-10-19 11:40:57 +11:00
parent 2dc9109b11
commit 634410294b
5 changed files with 45 additions and 2 deletions

View File

@ -0,0 +1,34 @@
{% extends "order/order_base.html" %}
{% load inventree_extras %}
{% load i18n %}
{% load static %}
{% block details %}
{% include 'order/po_tabs.html' with tab='received' %}
<h4>{% trans "Received Items" %}</h4>
<hr>
{% include "stock_table.html" with read_only=True %}
{% endblock %}
{% block js_ready %}
{{ block.super }}
loadStockTable($("#stock-table"), {
params: {
purchase_order: {{ order.id }},
part_detail: true,
supplier_detail: true,
location_detail: true,
},
buttons: [
'#stock-options',
],
filterkey: "postock"
});
{% endblock %}

View File

@ -2,7 +2,10 @@
<ul class='nav nav-tabs'>
<li{% ifequal tab 'details' %} class='active'{% endifequal %}>
<a href="{% url 'po-detail' order.id %}">{% trans "Items" %}</a>
<a href="{% url 'po-detail' order.id %}">{% trans "Line Items" %}</a>
</li>
<li {% if tab == 'received' %} class='active'{% endif %}>
<a href="{% url 'po-received' order.id %}">{% trans "Received Items" %}</a>
</li>
<li{% if tab == 'attachments' %} class='active'{% endif %}>
<a href="{% url 'po-attachments' order.id %}">{% trans "Attachments" %}

View File

@ -21,6 +21,7 @@ purchase_order_detail_urls = [
url(r'^notes/', views.PurchaseOrderNotes.as_view(), name='po-notes'),
url(r'^received/', views.PurchaseOrderDetail.as_view(template_name='order/po_received_items.html'), name='po-received'),
url(r'^attachments/', views.PurchaseOrderDetail.as_view(template_name='order/po_attachments.html'), name='po-attachments'),
url(r'^.*$', views.PurchaseOrderDetail.as_view(), name='po-detail'),
]

View File

@ -498,6 +498,11 @@ class StockList(generics.ListCreateAPIView):
if sales_order:
queryset = queryset.filter(sales_order=sales_order)
purchase_order = params.get('purchase_order', None)
if purchase_order is not None:
queryset = queryset.filter(purchase_order=purchase_order)
# Filter stock items which are installed in another (specific) stock item
installed_in = params.get('installed_in', None)

View File

@ -262,7 +262,7 @@ function loadStockTable(table, options) {
formatNoMatches: function() {
return '{% trans "No stock items matching query" %}';
},
url: options.url,
url: options.url || "{% url 'api-stock-list' %}",
queryParams: filters,
customSort: customGroupSorter,
groupBy: true,