From a0c95579b42042ed992a3edb165a4aeb5d352b98 Mon Sep 17 00:00:00 2001 From: Oliver Walters <oliver.henry.walters@gmail.com> Date: Mon, 4 Jan 2021 00:21:47 +1100 Subject: [PATCH] Display expiry status on StockItem page - Also adds ability to filter Stock table by expired status --- InvenTree/stock/templates/stock/item_base.html | 15 +++++++++++++++ InvenTree/templates/js/stock.js | 4 ++++ InvenTree/templates/js/table_filters.js | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 74e93fecc0..4d773b047d 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -71,6 +71,9 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} <h3> {% trans "Stock Item" %} {% stock_status_label item.status large=True %} + {% if item.is_expired %} + <span class='label label-large label-large-red'>{% trans "Expired" %}</span> + {% endif %} </h3> <hr> <h4> @@ -293,6 +296,18 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} <td><a href="{% url 'supplier-part-detail' item.supplier_part.id %}">{{ item.supplier_part.SKU }}</a></td> </tr> {% endif %} + {% if item.expiry_date %} + <tr> + <td><span class='fas fa-calendar-alt{% if item.is_expired %} icon-red{% endif %}'></span></td> + <td>{% trans "Expiry Date" %}</td> + <td> + {{ item.expiry_date }} + {% if item.is_expired %} + <span title='[% trans "This StockItem expired on" %} {{ item.expiry_date }}' class='label label-red'>{% trans "Expired" %}</span> + {% endif %} + </td> + </tr> + {% endif %} <tr> <td><span class='fas fa-calendar-alt'></span></td> <td>{% trans "Last Updated" %}</td> diff --git a/InvenTree/templates/js/stock.js b/InvenTree/templates/js/stock.js index f8a7c38d2c..65df58c4b6 100644 --- a/InvenTree/templates/js/stock.js +++ b/InvenTree/templates/js/stock.js @@ -532,6 +532,10 @@ function loadStockTable(table, options) { html += makeIconBadge('fa-user', '{% trans "Stock item assigned to customer" %}'); } + if (row.expired) { + html += makeIconBadge('fa-stopwatch icon-red', '{% trans "Stock item has expired" %}'); + } + if (row.allocated) { html += makeIconBadge('fa-bookmark', '{% trans "Stock item has been allocated" %}'); } diff --git a/InvenTree/templates/js/table_filters.js b/InvenTree/templates/js/table_filters.js index d2ea26d8c3..054542a4a3 100644 --- a/InvenTree/templates/js/table_filters.js +++ b/InvenTree/templates/js/table_filters.js @@ -106,6 +106,11 @@ function getAvailableTableFilters(tableKey) { title: '{% trans "Depleted" %}', description: '{% trans "Show stock items which are depleted" %}', }, + expired: { + type: 'bool', + title: '{% trans "Expired" %}', + description: '{% trans "Show stock items which have expired" %}', + }, in_stock: { type: 'bool', title: '{% trans "In Stock" %}',