mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #682 from SchrodingersGat/low-stock
"Low Stock" badge
This commit is contained in:
commit
e28fe6df6a
@ -112,6 +112,10 @@
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.label-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* Bootstrap table overrides */
|
||||
|
||||
.stock-sub-group td {
|
||||
|
@ -182,25 +182,27 @@ function loadPartTable(table, url, options={}) {
|
||||
searchable: false,
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
var html = "";
|
||||
var link = "stock";
|
||||
|
||||
|
||||
if (value) {
|
||||
// There IS stock available for this part
|
||||
|
||||
if (row.units) {
|
||||
value += ' <i><small>' + row.units + '</small></i>';
|
||||
// Is stock "low" (below the 'minimum_stock' quantity)?
|
||||
if (row.minimum_stock && row.minimum_stock > value) {
|
||||
value += "<span class='label label-right label-warning'>Low stock</span>";
|
||||
}
|
||||
|
||||
html = value;
|
||||
|
||||
} else if (row.on_order) {
|
||||
value = "<span class='label label-primary'>On Order : " + row.on_order + "</span>";
|
||||
// There is no stock available, but stock is on order
|
||||
value = "0<span class='label label-right label-primary'>On Order : " + row.on_order + "</span>";
|
||||
link = "orders";
|
||||
} else if (row.building) {
|
||||
value = "<span class='label label-info'>Building : " + row.building + "</span>";
|
||||
// There is no stock available, but stock is being built
|
||||
value = "0<span class='label label-right label-info'>Building : " + row.building + "</span>";
|
||||
link = "builds";
|
||||
} else {
|
||||
value ="<span class='label label-warning'>No Stock</span>";
|
||||
// There is no stock available
|
||||
value = "0<span class='label label-right label-danger'>No Stock</span>";
|
||||
}
|
||||
|
||||
return renderLink(value, '/part/' + row.pk + "/" + link + "/");
|
||||
|
@ -178,6 +178,7 @@ class PartList(generics.ListCreateAPIView):
|
||||
'is_template',
|
||||
'URL',
|
||||
'units',
|
||||
'minimum_stock',
|
||||
'trackable',
|
||||
'assembly',
|
||||
'component',
|
||||
|
@ -98,7 +98,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "In Stock" %}</td>
|
||||
<td>{% decimal part.total_stock %}</td>
|
||||
<td>{% include "part/stock_count.html" %}</td>
|
||||
</tr>
|
||||
{% if not part.is_template %}
|
||||
{% if part.allocation_count > 0 %}
|
||||
|
10
InvenTree/part/templates/part/stock_count.html
Normal file
10
InvenTree/part/templates/part/stock_count.html
Normal file
@ -0,0 +1,10 @@
|
||||
{% load inventree_extras %}
|
||||
{% load i18n %}
|
||||
|
||||
{% decimal part.total_stock %}
|
||||
|
||||
{% if part.total_stock == 0 %}
|
||||
<span class='label label-danger'>{% trans "No Stock" %}</span>
|
||||
{% elif part.total_stock < part.minimum_stock %}
|
||||
<span class='label label-warning'>{% trans "Low Stock" %}</span>
|
||||
{% endif %}
|
Loading…
Reference in New Issue
Block a user