From 9e82b28e9d42583757ede46c51417163b79f4fd2 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 28 Feb 2022 15:03:39 +1100 Subject: [PATCH] Update PO line item table --- .../order/purchase_order_detail.html | 2 +- InvenTree/templates/js/translated/order.js | 35 ++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index d0215777bb..74ce484e7a 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -210,7 +210,7 @@ $('#new-po-line').click(function() { loadPurchaseOrderLineItemTable('#po-line-table', { order: {{ order.pk }}, supplier: {{ order.supplier.pk }}, - {% if order.status == PurchaseOrderStatus.PENDING %} + {% if roles.purchase_order.change %} allow_edit: true, {% else %} allow_edit: false, diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index 008091bf15..3dfe112381 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -930,6 +930,7 @@ function loadPurchaseOrderLineItemTable(table, options={}) { reference: {}, purchase_price: {}, purchase_price_currency: {}, + target_date: {}, destination: {}, notes: {}, }, @@ -971,7 +972,11 @@ function loadPurchaseOrderLineItemTable(table, options={}) { ], { success: function() { + // Reload the line item table $(table).bootstrapTable('refresh'); + + // Reload the "received stock" table + $('#stock-table').bootstrapTable('refresh'); } } ); @@ -1111,6 +1116,28 @@ function loadPurchaseOrderLineItemTable(table, options={}) { return formatter.format(total); } }, + { + sortable: true, + field: 'target_date', + switchable: true, + title: '{% trans "Target Date" %}', + formatter: function(value, row) { + if (row.target_date) { + var html = row.target_date; + + if (row.overdue) { + html += ``; + } + + return html; + + } else if (row.order_detail && row.order_detail.target_date) { + return `${row.order_detail.target_date}`; + } else { + return '-'; + } + } + }, { sortable: false, field: 'received', @@ -1157,15 +1184,15 @@ function loadPurchaseOrderLineItemTable(table, options={}) { var pk = row.pk; + if (options.allow_receive && row.received < row.quantity) { + html += makeIconButton('fa-sign-in-alt icon-green', 'button-line-receive', pk, '{% trans "Receive line item" %}'); + } + if (options.allow_edit) { html += makeIconButton('fa-edit icon-blue', 'button-line-edit', pk, '{% trans "Edit line item" %}'); html += makeIconButton('fa-trash-alt icon-red', 'button-line-delete', pk, '{% trans "Delete line item" %}'); } - if (options.allow_receive && row.received < row.quantity) { - html += makeIconButton('fa-sign-in-alt', 'button-line-receive', pk, '{% trans "Receive line item" %}'); - } - html += ``; return html;