Adds ability to filter stock API results by batch code

This commit is contained in:
Oliver Walters committed 2020-09-23 09:11:46 +10:00
1 parent fb247c3dd8
commit 8a4597be6a
2 files changed
+14

No files matched your search

+6
View File
@@ -455,6 +455,12 @@ class StockList(generics.ListCreateAPIView):
if belongs_to: if belongs_to:
queryset = queryset.filter(belongs_to=belongs_to) queryset = queryset.filter(belongs_to=belongs_to)
# Filter by batch code
batch = params.get('batch', None)
if batch is not None:
queryset = queryset.filter(batch=batch)
build = params.get('build', None) build = params.get('build', None)
if build: if build:
@@ -30,6 +30,10 @@ function getAvailableTableFilters(tableKey) {
title: "{% trans "Serial number" %}", title: "{% trans "Serial number" %}",
description: "{% trans "Serial number" %}" description: "{% trans "Serial number" %}"
}, },
batch: {
title: '{% trans "Batch" %}',
description: '{% trans "Batch code" %}',
},
}; };
} }
@@ -87,6 +91,10 @@ function getAvailableTableFilters(tableKey) {
title: '{% trans "Stock status" %}', title: '{% trans "Stock status" %}',
description: '{% trans "Stock status" %}', description: '{% trans "Stock status" %}',
}, },
batch: {
title: '{% trans "Batch" %}',
description: '{% trans "Batch code" %}',
}
}; };
} }