Merge pull request #898 from SchrodingersGat/filter-depleted

Filter depleted
This commit is contained in:
Oliver 2020-08-08 17:19:28 +10:00 committed by GitHub
commit fcfd1f82d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 16 deletions

View File

@ -26,7 +26,8 @@
},
buttons: [
'#stock-options',
]
],
filterKey: "companystock",
});
$("#stock-export").click(function() {

View File

@ -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?

View File

@ -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;
}
},

View File

@ -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" %}',
},
};
}