Display stale stock on index page

This commit is contained in:
Oliver Walters 2021-01-06 22:30:12 +11:00
parent e62873a650
commit a5b18640af
4 changed files with 42 additions and 64 deletions

View File

@ -3,7 +3,7 @@
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-stopwatch icon-header'></span>
<span class='fas fa-calendar-times icon-header'></span>
{% trans "Expired Stock" %}<span class='badge' id='expired-stock-count'><span class='fas fa-spin fa-spinner'></span></span>
{% endblock %}

View File

@ -26,6 +26,7 @@ InvenTree | {% trans "Index" %}
{% settings_value "STOCK_ENABLE_EXPIRY" as expiry %}
{% if expiry %}
{% include "InvenTree/expired_stock.html" with collapse_id="expired" %}
{% include "InvenTree/stale_stock.html" with collapse_id="stale" %}
{% endif %}
{% include "InvenTree/required_stock_build.html" with collapse_id="stock_to_build" %}
{% endif %}
@ -98,6 +99,14 @@ loadStockTable($("#expired-stock-table"), {
},
});
loadStockTable($("#stale-stock-table"), {
params: {
stale: true,
location_detail: true,
part_detail: true,
},
});
loadSimplePartTable("#low-stock-table", "{% url 'api-part-list' %}", {
params: {
low_stock: true,
@ -136,70 +145,19 @@ loadSalesOrderTable("#so-overdue-table", {
}
});
$("#latest-parts-table").on('load-success.bs.table', function() {
var count = $("#latest-parts-table").bootstrapTable('getData').length;
{% include "InvenTree/index/on_load.html" with label="latest-parts" %}
{% include "InvenTree/index/on_load.html" with label="starred-parts" %}
{% include "InvenTree/index/on_load.html" with label="bom-invalid" %}
{% include "InvenTree/index/on_load.html" with label="build-pending" %}
{% include "InvenTree/index/on_load.html" with label="build-overdue" %}
$("#latest-parts-count").html(count);
});
{% include "InvenTree/index/on_load.html" with label="expired-stock" %}
{% include "InvenTree/index/on_load.html" with label="stale-stock" %}
{% include "InvenTree/index/on_load.html" with label="low-stock" %}
{% include "InvenTree/index/on_load.html" with label="stock-to-build" %}
$("#starred-parts-table").on('load-success.bs.table', function() {
var count = $("#starred-parts-table").bootstrapTable('getData').length;
$("#starred-parts-count").html(count);
});
$("#bom-invalid-table").on('load-success.bs.table', function() {
var count = $("#bom-invalid-table").bootstrapTable('getData').length;
$("#bom-invalid-count").html(count);
});
$("#build-pending-table").on('load-success.bs.table', function() {
var count = $("#build-pending-table").bootstrapTable('getData').length;
$("#build-pending-count").html(count);
});
$("#build-overdue-table").on('load-success.bs.table', function() {
var count = $("#build-overdue-table").bootstrapTable('getData').length;
$("#build-overdue-count").html(count);
});
$("#expired-stock-table").on('load-success.bs.table', function() {
var count = $("#expired-stock-table").bootstrapTable('getData').length;
$("#expired-stock-count").html(count);
});
$("#low-stock-table").on('load-success.bs.table', function() {
var count = $("#low-stock-table").bootstrapTable('getData').length;
$("#low-stock-count").html(count);
});
$("#stock-to-build-table").on('load-success.bs.table', function() {
var count = $("#stock-to-build-table").bootstrapTable('getData').length;
$("#stock-to-build-count").html(count);
});
$("#po-outstanding-table").on('load-success.bs.table', function() {
var count = $("#po-outstanding-table").bootstrapTable('getData').length;
$("#po-outstanding-count").html(count);
});
$("#so-outstanding-table").on('load-success.bs.table', function() {
var count = $("#so-outstanding-table").bootstrapTable('getData').length;
$("#so-outstanding-count").html(count);
});
$("#so-overdue-table").on('load-success.bs.table', function() {
var count = $("#so-overdue-table").bootstrapTable('getData').length;
$("#so-overdue-count").html(count);
});
{% include "InvenTree/index/on_load.html" with label="po-outstanding" %}
{% include "InvenTree/index/on_load.html" with label="so-outstanding" %}
{% include "InvenTree/index/on_load.html" with label="so-overdue" %}
{% endblock %}

View File

@ -0,0 +1,5 @@
$("#{{ label }}-table").on('load-success.bs.table', function() {
var count = $("#{{ label }}-table").bootstrapTable('getData').length;
$("#{{ label }}-count").html(count);
});

View File

@ -0,0 +1,15 @@
{% extends "collapse_index.html" %}
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-stopwatch icon-header'></span>
{% trans "Stale Stock" %}<span class='badge' id='stale-stock-count'><span class='fas fa-spin fa-spinner'></span></span>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='stale-stock-table'>
</table>
{% endblock %}