Merge pull request #1747 from matmair/depleted-stock

Depleted stock on start page
This commit is contained in:
Oliver 2021-07-03 16:23:27 +10:00 committed by GitHub
commit 45704f7a8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -651,6 +651,15 @@ class PartList(generics.ListCreateAPIView):
# Filter items which have an 'in_stock' level higher than 'minimum_stock' # Filter items which have an 'in_stock' level higher than 'minimum_stock'
queryset = queryset.filter(Q(in_stock__gte=F('minimum_stock'))) queryset = queryset.filter(Q(in_stock__gte=F('minimum_stock')))
# Filer by 'depleted_stock' status -> has no stock and stock items
depleted_stock = params.get('depleted_stock', None)
if depleted_stock is not None:
depleted_stock = str2bool(depleted_stock)
if depleted_stock:
queryset = queryset.filter(Q(in_stock=0) & ~Q(stock_item_count=0))
# Filter by "parts which need stock to complete build" # Filter by "parts which need stock to complete build"
stock_to_build = params.get('stock_to_build', None) stock_to_build = params.get('stock_to_build', None)

View File

@ -128,6 +128,7 @@ loadSimplePartTable("#table-bom-validation", "{% url 'api-part-list' %}", {
addHeaderTitle('{% trans "Stock" %}'); addHeaderTitle('{% trans "Stock" %}');
addHeaderAction('recently-updated-stock', '{% trans "Recently Updated" %}', 'fa-clock'); addHeaderAction('recently-updated-stock', '{% trans "Recently Updated" %}', 'fa-clock');
addHeaderAction('low-stock', '{% trans "Low Stock" %}', 'fa-shopping-cart'); addHeaderAction('low-stock', '{% trans "Low Stock" %}', 'fa-shopping-cart');
addHeaderAction('depleted-stock', '{% trans "Depleted Stock" %}', 'fa-times');
addHeaderAction('stock-to-build', '{% trans "Required for Build Orders" %}', 'fa-bullhorn'); addHeaderAction('stock-to-build', '{% trans "Required for Build Orders" %}', 'fa-bullhorn');
loadStockTable($('#table-recently-updated-stock'), { loadStockTable($('#table-recently-updated-stock'), {
@ -170,6 +171,13 @@ loadSimplePartTable("#table-low-stock", "{% url 'api-part-list' %}", {
name: "low_stock_parts", name: "low_stock_parts",
}); });
loadSimplePartTable("#table-depleted-stock", "{% url 'api-part-list' %}", {
params: {
depleted_stock: true,
},
name: "depleted_stock_parts",
});
loadSimplePartTable("#table-stock-to-build", "{% url 'api-part-list' %}", { loadSimplePartTable("#table-stock-to-build", "{% url 'api-part-list' %}", {
params: { params: {
stock_to_build: true, stock_to_build: true,