mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Tree exclusion for PartCategory and StockLocation
This commit is contained in:
parent
bee0a519ef
commit
85a40ec418
@ -105,6 +105,20 @@ class CategoryList(generics.ListCreateAPIView):
|
|||||||
except (ValueError, PartCategory.DoesNotExist):
|
except (ValueError, PartCategory.DoesNotExist):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Exclude PartCategory tree
|
||||||
|
exclude_tree = params.get('exclude_tree', None)
|
||||||
|
|
||||||
|
if exclude_tree is not None:
|
||||||
|
try:
|
||||||
|
cat = PartCategory.objects.get(pk=exclude_tree)
|
||||||
|
|
||||||
|
queryset = queryset.exclude(
|
||||||
|
pk__in=[c.pk for c in cat.get_descendants(include_self=True)]
|
||||||
|
)
|
||||||
|
|
||||||
|
except (ValueError, PartCategory.DoesNotExist):
|
||||||
|
pass
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
filter_backends = [
|
filter_backends = [
|
||||||
|
@ -343,6 +343,20 @@ class StockLocationList(generics.ListCreateAPIView):
|
|||||||
except (ValueError, StockLocation.DoesNotExist):
|
except (ValueError, StockLocation.DoesNotExist):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Exclude StockLocation tree
|
||||||
|
exclude_tree = params.get('exclude_tree', None)
|
||||||
|
|
||||||
|
if exclude_tree is not None:
|
||||||
|
try:
|
||||||
|
loc = StockLocation.objects.get(pk=exclude_tree)
|
||||||
|
|
||||||
|
queryset = queryset.exclude(
|
||||||
|
pk__in=[l.pk for l in loc.get_descendants(include_self=True)]
|
||||||
|
)
|
||||||
|
|
||||||
|
except (ValueError, StockLocation.DoesNotExist):
|
||||||
|
pass
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
filter_backends = [
|
filter_backends = [
|
||||||
|
Loading…
Reference in New Issue
Block a user