mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Use the client-side PO table in more places
This commit is contained in:
parent
a257f94ac0
commit
71c1faf9ff
@ -100,6 +100,63 @@ function removePurchaseOrderLineItem(e) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function loadPurchaseOrderTable(table, options) {
|
||||
/* Create a purchase-order table */
|
||||
|
||||
table.inventreeTable({
|
||||
url: options.url,
|
||||
formatNoMatches: function() { return "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 + '/purchase-orders/');
|
||||
}
|
||||
},
|
||||
{
|
||||
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',
|
||||
title: 'Status',
|
||||
formatter: function(value, row, index, field) {
|
||||
return orderStatusLabel(row.status, row.status_text);
|
||||
}
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'lines',
|
||||
title: 'Items'
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function orderStatusLabel(code, label) {
|
||||
/* Render a purchase-order status label. */
|
||||
|
||||
|
@ -13,17 +13,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "order/po_table.html" with orders=company.outstanding_purchase_orders.all toolbar='#button-bar' %}
|
||||
|
||||
{% if company.closed_purchase_orders.count > 0 %}
|
||||
{% include "order/po_table_collapse.html" with title="Closed Orders" orders=company.closed_purchase_orders.all %}
|
||||
{% endif %}
|
||||
<table class='table table-striped table-condensed po-table' id='purchase-order-table' data-toolbar='#button-bar'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
loadPurchaseOrderTable($("#purchase-order-table"), {
|
||||
url: "{% url 'api-po-list' %}?supplier={{ company.id }}",
|
||||
});
|
||||
|
||||
|
||||
function newOrder() {
|
||||
launchModalForm("{% url 'purchase-order-create' %}",
|
||||
{
|
||||
|
@ -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',
|
||||
|
@ -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 %}
|
@ -14,19 +14,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "order/po_table.html" with orders=part.open_purchase_orders toolbar='#button-bar' %}
|
||||
<table class='table table-striped table-condensed po-table' id='purchase-order-table' data-toolbar='#button-bar'>
|
||||
</table>
|
||||
|
||||
{% if part.closed_purchase_orders|length > 0 %}
|
||||
<h4>Closed Orders</h4>
|
||||
{% include "order/po_table.html" with orders=part.closed_purchase_orders %}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
$("#po-table").inventreeTable({
|
||||
loadPurchaseOrderTable($("#purchase-order-table"), {
|
||||
url: "{% url 'api-po-list' %}?part={{ part.id }}",
|
||||
});
|
||||
|
||||
$("#part-order2").click(function() {
|
||||
|
Loading…
Reference in New Issue
Block a user