2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 20:45:44 +00:00

Use the client-side PO table in more places

This commit is contained in:
Oliver Walters
2019-12-09 21:55:00 +11:00
parent a257f94ac0
commit 71c1faf9ff
5 changed files with 79 additions and 59 deletions

View File

@ -17,6 +17,8 @@ from InvenTree.status_codes import OrderStatus
import os
from part.models import Part
from .models import PurchaseOrder, PurchaseOrderLineItem
from .serializers import POSerializer, POLineItemSerializer
@ -52,6 +54,14 @@ class POList(generics.ListCreateAPIView):
except ValueError:
pass
# Attempt to filter by part
if 'part' in request.GET:
try:
part = Part.objects.get(pk=request.GET['part'])
queryset = queryset.filter(id__in=[p.id for p in part.purchase_orders()])
except (Part.DoesNotExist, ValueError):
pass
data = queryset.values(
'pk',
'supplier',

View File

@ -37,55 +37,8 @@ $("#po-create").click(function() {
$("#po-table").inventreeTable({
});
$("#purchase-order-table").inventreeTable({
loadPurchaseOrderTable($("#purchase-order-table"), {
url: "{% url 'api-po-list' %}",
formatNoMatches: function() { return "{% trans "No purchase orders found" %}"; },
columns: [
{
field: 'pk',
title: 'ID',
visible: false,
},
{
sortable: true,
field: 'supplier',
title: 'Supplier',
formatter: function(value, row, index, field) {
return imageHoverIcon(row.supplier__image) + renderLink(row.supplier__name, '/company/' + value + '/');
}
},
{
sortable: true,
field: 'reference',
title: 'Reference',
formatter: function(value, row, index, field) {
return renderLink(value, "/order/purchase-order/" + row.pk + "/");
}
},
{
sortable: true,
field: 'creation_date',
title: 'Date',
},
{
sortable: true,
field: 'description',
title: 'Description',
},
{
sortable: true,
field: 'status_text',
title: 'Status',
formatter: function(value, row, index, field) {
return orderStatusLabel(row.status, row.status_text);
}
},
{
sortable: true,
field: 'lines',
title: 'Items'
},
],
});
{% endblock %}