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