mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Fix for 'available' filter (#4952)
- Available filter also requires "in stock"
This commit is contained in:
		@@ -444,7 +444,8 @@ class StockFilter(rest_filters.FilterSet):
 | 
				
			|||||||
        """
 | 
					        """
 | 
				
			||||||
        if str2bool(value):
 | 
					        if str2bool(value):
 | 
				
			||||||
            # The 'quantity' field is greater than the calculated 'allocated' field
 | 
					            # 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:
 | 
					        else:
 | 
				
			||||||
            # The 'quantity' field is less than (or equal to) the calculated 'allocated' field
 | 
					            # The 'quantity' field is less than (or equal to) the calculated 'allocated' field
 | 
				
			||||||
            return queryset.filter(Q(quantity__lte=F('allocated')))
 | 
					            return queryset.filter(Q(quantity__lte=F('allocated')))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user