Add ability to display "out of stock" items against a part

This commit is contained in:
Oliver Walters 2020-06-22 10:48:41 +10:00
parent 16bea33695
commit 930f903f5d
7 changed files with 15 additions and 14 deletions

View File

@ -14,7 +14,7 @@
function defaultFilters() {
return {
stock: "cascade=1",
stock: "cascade=1&in_stock=1",
build: "",
parts: "cascade=1",
company: "",

View File

@ -40,7 +40,6 @@
part: {{ part.id }},
location_detail: true,
part_detail: true,
in_stock: true,
},
groupByField: 'location',
buttons: [

View File

@ -51,15 +51,6 @@
</li>
{% endif %}
{% if part.trackable %}
{% if 0 %}
<!-- TODO - Add the 'tracking' tab back in -->
<li{% ifequal tab 'track' %} class="active"{% endifequal %}>
<a href="{% url 'part-track' part.id %}">{% trans "Tracking" %}
{% if parts.serials.all|length > 0 %}
<span class="badge">{{ part.serials.all|length }}</span>
{% endif %}
</a></li>
{% endif %}
<li{% ifequal tab 'tests' %} class='active'{% endifequal %}>
<a href='{% url "part-test-templates" part.id %}'>{% trans "Tests" %}
{% if part.getTestTemplates.count > 0 %}<span class='badge'>{{ part.getTestTemplates.count }}</span>{% endif %}

View File

@ -71,6 +71,7 @@ class StockItemSerializer(InvenTreeModelSerializer):
'belongs_to',
'build',
'build_order',
'customer',
'sales_order',
'supplier_part',
'supplier_part__supplier',
@ -141,6 +142,7 @@ class StockItemSerializer(InvenTreeModelSerializer):
'batch',
'build_order',
'belongs_to',
'customer',
'in_stock',
'link',
'location',

View File

@ -248,7 +248,6 @@
{% endif %}
part_detail: true,
location_detail: true,
in_stock: true,
},
url: "{% url 'api-stock-list' %}",
});

View File

@ -494,10 +494,15 @@ function loadStockTable(table, options) {
sortable: true,
formatter: function(value, row, index, field) {
if (value) {
return renderLink(value, '/stock/location/' + row.location + '/');
return renderLink(value, `/stock/location/${row.location}/`);
}
else {
return '<i>{% trans "No stock location set" %}</i>';
if (row.customer) {
var text = "{% trans "Shipped to customer" %}";
return renderLink(text, `/company/${row.customer}/assigned-stock/`);
} else {
return '<i>{% trans "No stock location set" %}</i>';
}
}
}
},

View File

@ -14,6 +14,11 @@ function getAvailableTableFilters(tableKey) {
// Filters for the "Stock" table
if (tableKey == 'stock') {
return {
in_stock: {
type: 'bool',
title: '{% trans "In Stock" %}',
description: '{% trans "Show items which are in stock" %}',
},
cascade: {
type: 'bool',
title: '{% trans "Include sublocations" %}',