2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-07 07:48:50 +00:00

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%; font-size: 100%;
} }
.label-right {
float: right;
}
/* Bootstrap table overrides */ /* Bootstrap table overrides */
.stock-sub-group td { .stock-sub-group td {

View File

@ -182,25 +182,27 @@ function loadPartTable(table, url, options={}) {
searchable: false, searchable: false,
sortable: true, sortable: true,
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
var html = "";
var link = "stock"; var link = "stock";
if (value) { if (value) {
// There IS stock available for this part
if (row.units) { // Is stock "low" (below the 'minimum_stock' quantity)?
value += ' <i><small>' + row.units + '</small></i>'; 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) { } 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"; link = "orders";
} else if (row.building) { } 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"; link = "builds";
} else { } 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 + "/"); return renderLink(value, '/part/' + row.pk + "/" + link + "/");

View File

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

View File

@ -57,6 +57,31 @@
{ {
field: 'status', field: 'status',
title: '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', field: 'completion_date',

View File

@ -98,7 +98,7 @@
</tr> </tr>
<tr> <tr>
<td>{% trans "In Stock" %}</td> <td>{% trans "In Stock" %}</td>
<td>{% decimal part.total_stock %}</td> <td>{% include "part/stock_count.html" %}</td>
</tr> </tr>
{% if not part.is_template %} {% if not part.is_template %}
{% if part.allocation_count > 0 %} {% 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 %}