Merge pull request #874 from SchrodingersGat/show_non_stock

Add ability to display "out of stock" items against a part
This commit is contained in:
Oliver 2020-06-22 10:55:12 +10:00 committed by GitHub
commit da70af7ba0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 14 deletions

View File

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

View File

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

View File

@ -51,15 +51,6 @@
</li> </li>
{% endif %} {% endif %}
{% if part.trackable %} {% 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 %}> <li{% ifequal tab 'tests' %} class='active'{% endifequal %}>
<a href='{% url "part-test-templates" part.id %}'>{% trans "Tests" %} <a href='{% url "part-test-templates" part.id %}'>{% trans "Tests" %}
{% if part.getTestTemplates.count > 0 %}<span class='badge'>{{ part.getTestTemplates.count }}</span>{% endif %} {% if part.getTestTemplates.count > 0 %}<span class='badge'>{{ part.getTestTemplates.count }}</span>{% endif %}

View File

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

View File

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

View File

@ -494,12 +494,17 @@ function loadStockTable(table, options) {
sortable: true, sortable: true,
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
if (value) { if (value) {
return renderLink(value, '/stock/location/' + row.location + '/'); return renderLink(value, `/stock/location/${row.location}/`);
} }
else { else {
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>'; return '<i>{% trans "No stock location set" %}</i>';
} }
} }
}
}, },
{ {
field: 'notes', field: 'notes',

View File

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