mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add option to filter out variants in stock table
This commit is contained in:
parent
b95d6a4ab2
commit
dffff89e9d
@ -684,10 +684,17 @@ class StockList(generics.ListCreateAPIView):
|
|||||||
try:
|
try:
|
||||||
part = Part.objects.get(pk=part_id)
|
part = Part.objects.get(pk=part_id)
|
||||||
|
|
||||||
# Filter by any parts "under" the given part
|
# Do we wish to filter *just* for this part, or also for parts *under* this one?
|
||||||
parts = part.get_descendants(include_self=True)
|
include_variants = str2bool(params.get('include_variants', True))
|
||||||
|
|
||||||
queryset = queryset.filter(part__in=parts)
|
if include_variants:
|
||||||
|
# Filter by any parts "under" the given part
|
||||||
|
parts = part.get_descendants(include_self=True)
|
||||||
|
|
||||||
|
queryset = queryset.filter(part__in=parts)
|
||||||
|
|
||||||
|
else:
|
||||||
|
queryset = queryset.filter(part=part)
|
||||||
|
|
||||||
except (ValueError, Part.DoesNotExist):
|
except (ValueError, Part.DoesNotExist):
|
||||||
raise ValidationError({"part": "Invalid Part ID specified"})
|
raise ValidationError({"part": "Invalid Part ID specified"})
|
||||||
|
@ -130,6 +130,11 @@ function getAvailableTableFilters(tableKey) {
|
|||||||
title: '{% trans "In Production" %}',
|
title: '{% trans "In Production" %}',
|
||||||
description: '{% trans "Show items which are in production" %}',
|
description: '{% trans "Show items which are in production" %}',
|
||||||
},
|
},
|
||||||
|
include_variants: {
|
||||||
|
type: 'bool',
|
||||||
|
title: '{% trans "Include Variants" %}',
|
||||||
|
description: '{% trans "Include stock items for variant parts" %}',
|
||||||
|
},
|
||||||
installed: {
|
installed: {
|
||||||
type: 'bool',
|
type: 'bool',
|
||||||
title: '{% trans "Installed" %}',
|
title: '{% trans "Installed" %}',
|
||||||
|
Loading…
Reference in New Issue
Block a user