From a8e6d0a89ff75ad583ba69cfd07049763b7ca39b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 14 Jan 2021 17:37:10 +1100 Subject: [PATCH] Display overdue status in purchase order table - Allow table to be filtered by "overdue" status --- InvenTree/order/serializers.py | 1 + InvenTree/templates/js/order.js | 25 ++++++++++++++++++------- InvenTree/templates/js/table_filters.js | 4 ++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index 264523bb40..a04798c303 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -86,6 +86,7 @@ class POSerializer(InvenTreeModelSerializer): 'supplier_reference', 'status', 'status_text', + 'target_date', 'notes', ] diff --git a/InvenTree/templates/js/order.js b/InvenTree/templates/js/order.js index 18c315d17e..53063cd709 100644 --- a/InvenTree/templates/js/order.js +++ b/InvenTree/templates/js/order.js @@ -141,9 +141,9 @@ function loadPurchaseOrderTable(table, options) { switchable: false, }, { - sortable: true, field: 'reference', title: '{% trans "Purchase Order" %}', + sortable: true, switchable: false, formatter: function(value, row, index, field) { @@ -153,13 +153,19 @@ function loadPurchaseOrderTable(table, options) { value = `${prefix}${value}`; } - return renderLink(value, `/order/purchase-order/${row.pk}/`); + var html = renderLink(value, `/order/purchase-order/${row.pk}/`); + + if (row.overdue) { + html += makeIconBadge('fa-calendar-times icon-red', '{% trans "Order is overdue" %}'); + } + + return html; } }, { - sortable: true, field: 'supplier_detail', title: '{% trans "Supplier" %}', + sortable: true, formatter: function(value, row, index, field) { return imageHoverIcon(row.supplier_detail.image) + renderLink(row.supplier_detail.name, `/company/${row.supplier}/purchase-orders/`); } @@ -170,27 +176,32 @@ function loadPurchaseOrderTable(table, options) { sortable: true, }, { - sortable: true, field: 'description', title: '{% trans "Description" %}', + sortable: true, }, { - sortable: true, field: 'status', title: '{% trans "Status" %}', + sortable: true, formatter: function(value, row, index, field) { return purchaseOrderStatusDisplay(row.status, row.status_text); } }, { - sortable: true, field: 'creation_date', title: '{% trans "Date" %}', + sortable: true, }, { + field: 'target_date', + title: '{% trans "Target Date" %}', sortable: true, + }, + { field: 'line_items', - title: '{% trans "Items" %}' + title: '{% trans "Items" %}', + sortable: true, }, ], }); diff --git a/InvenTree/templates/js/table_filters.js b/InvenTree/templates/js/table_filters.js index 84aa12c139..81f72fb26d 100644 --- a/InvenTree/templates/js/table_filters.js +++ b/InvenTree/templates/js/table_filters.js @@ -214,6 +214,10 @@ function getAvailableTableFilters(tableKey) { type: 'bool', title: '{% trans "Outstanding" %}', }, + overdue: { + type: 'bool', + title: '{% trans "Overdue" %}', + }, }; }