mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #898 from SchrodingersGat/filter-depleted
Filter depleted
This commit is contained in:
commit
fcfd1f82d6
@ -26,7 +26,8 @@
|
||||
},
|
||||
buttons: [
|
||||
'#stock-options',
|
||||
]
|
||||
],
|
||||
filterKey: "companystock",
|
||||
});
|
||||
|
||||
$("#stock-export").click(function() {
|
||||
|
@ -539,10 +539,21 @@ class StockList(generics.ListCreateAPIView):
|
||||
active = str2bool(active)
|
||||
queryset = queryset.filter(part__active=active)
|
||||
|
||||
# Filter by 'depleted' status
|
||||
depleted = params.get('depleted', None)
|
||||
|
||||
if depleted is not None:
|
||||
depleted = str2bool(depleted)
|
||||
|
||||
if depleted:
|
||||
queryset = queryset.filter(quantity__lte=0)
|
||||
else:
|
||||
queryset = queryset.exclude(quantity__lte=0)
|
||||
|
||||
# Filter by internal part number
|
||||
IPN = params.get('IPN', None)
|
||||
|
||||
if IPN:
|
||||
if IPN is not None:
|
||||
queryset = queryset.filter(part__IPN=IPN)
|
||||
|
||||
# Does the client wish to filter by the Part ID?
|
||||
|
@ -468,6 +468,10 @@ function loadStockTable(table, options) {
|
||||
html += `<span class='fas fa-question-circle label-right' title='{% trans "StockItem is lost" %}'></span>`;
|
||||
}
|
||||
|
||||
if (row.quantity <= 0) {
|
||||
html += `<span class='label label-right label-danger'>{% trans "Depleted" %}</span>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
},
|
||||
|
@ -32,30 +32,30 @@ function getAvailableTableFilters(tableKey) {
|
||||
// Filters for the "Stock" table
|
||||
if (tableKey == 'stock') {
|
||||
return {
|
||||
in_stock: {
|
||||
active: {
|
||||
type: 'bool',
|
||||
title: '{% trans "In Stock" %}',
|
||||
description: '{% trans "Show items which are in stock" %}',
|
||||
title: '{% trans "Active parts" %}',
|
||||
description: '{% trans "Show stock for active parts" %}',
|
||||
},
|
||||
allocated: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Is allocated" %}',
|
||||
description: '{% trans "Item has been alloacted" %}',
|
||||
},
|
||||
cascade: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Include sublocations" %}',
|
||||
description: '{% trans "Include stock in sublocations" %}',
|
||||
},
|
||||
active: {
|
||||
depleted: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Active parts" %}',
|
||||
description: '{% trans "Show stock for active parts" %}',
|
||||
title: '{% trans "Depleted" %}',
|
||||
description: '{% trans "Show stock items which are depleted" %}',
|
||||
},
|
||||
status: {
|
||||
options: stockCodes,
|
||||
title: '{% trans "Stock status" %}',
|
||||
description: '{% trans "Stock status" %}',
|
||||
},
|
||||
allocated: {
|
||||
in_stock: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Is allocated" %}',
|
||||
description: '{% trans "Item has been alloacted" %}',
|
||||
title: '{% trans "In Stock" %}',
|
||||
description: '{% trans "Show items which are in stock" %}',
|
||||
},
|
||||
serialized: {
|
||||
type: 'bool',
|
||||
@ -69,6 +69,11 @@ function getAvailableTableFilters(tableKey) {
|
||||
title: "{% trans "Serial number LTE" %}",
|
||||
description: "{% trans "Serial number less than or equal to" %}",
|
||||
},
|
||||
status: {
|
||||
options: stockCodes,
|
||||
title: '{% trans "Stock status" %}',
|
||||
description: '{% trans "Stock status" %}',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user