From 5b6d9990914fa196a8ddd996ee3bee069c85fcd1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 17:06:09 +1000 Subject: [PATCH] Fix for 'available' filter (#4952) (#4954) - Available filter also requires "in stock" (cherry picked from commit c0dafe155fbaa872110bc53c5ce190b3fde53ada) Co-authored-by: Oliver --- InvenTree/stock/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index b54f311142..7183295207 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -434,7 +434,8 @@ class StockFilter(rest_filters.FilterSet): """ if str2bool(value): # The 'quantity' field is greater than the calculated 'allocated' field - return queryset.filter(Q(quantity__gt=F('allocated'))) + # Note that the item must also be "in stock" + return queryset.filter(StockItem.IN_STOCK_FILTER).filter(Q(quantity__gt=F('allocated'))) else: # The 'quantity' field is less than (or equal to) the calculated 'allocated' field return queryset.filter(Q(quantity__lte=F('allocated')))