From c0dafe155fbaa872110bc53c5ce190b3fde53ada Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 2 Jun 2023 16:37:16 +1000 Subject: [PATCH] Fix for 'available' filter (#4952) - Available filter also requires "in stock" --- 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 c5a8cb838c..54690223d6 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -444,7 +444,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')))