Merge remote-tracking branch 'inventree/master'

This commit is contained in:
Oliver Walters 2020-03-30 19:06:30 +11:00
commit b0edd0eb05
6 changed files with 52 additions and 10 deletions

View File

@ -112,6 +112,10 @@
font-size: 100%;
}
.label-right {
float: right;
}
/* Bootstrap table overrides */
.stock-sub-group td {

View File

@ -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 + "/");

View File

@ -178,6 +178,7 @@ class PartList(generics.ListCreateAPIView):
'is_template',
'URL',
'units',
'minimum_stock',
'trackable',
'assembly',
'component',

View File

@ -57,6 +57,31 @@
{
field: 'status',
title: 'Status',
formatter: function(value, row, index, field) {
var color = '';
switch (value) {
case 10: // Pending
color = 'label-info';
break;
case 20: // Allocated
color = 'label-primary';
break;
case 30: // Cancelled
color = 'label-danger';
break;
case 40: // Complete
color = 'label-success';
break;
default:
break;
}
var html = "<span class='label " + color + " label-large'>" + row.status_text + "</span>";
return html;
}
},
{
field: 'completion_date',

View File

@ -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 %}

View 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 %}