From 8a4597be6aa0dea118023e1f22d4d2abefc94f61 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 23 Sep 2020 09:11:46 +1000 Subject: [PATCH] Adds ability to filter stock API results by batch code --- InvenTree/stock/api.py | 6 ++++++ InvenTree/templates/js/table_filters.html | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 54cb5a62cf..900a94ed52 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -455,6 +455,12 @@ class StockList(generics.ListCreateAPIView): if 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) if build: diff --git a/InvenTree/templates/js/table_filters.html b/InvenTree/templates/js/table_filters.html index bd417882e3..316abcad7b 100644 --- a/InvenTree/templates/js/table_filters.html +++ b/InvenTree/templates/js/table_filters.html @@ -30,6 +30,10 @@ function getAvailableTableFilters(tableKey) { title: "{% 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" %}', description: '{% trans "Stock status" %}', }, + batch: { + title: '{% trans "Batch" %}', + description: '{% trans "Batch code" %}', + } }; }