2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-09-14 06:31:27 +00:00

BOM filter by category (#9989)

* Add "category" filter for BomItem API endpoint

* Filter BOM table by part category

* Tweak filter label

* Bump API version

* Schema annotation

* Fix playwright test
This commit is contained in:
Oliver
2025-07-09 21:46:07 +10:00
committed by GitHub
parent 6f08bdca46
commit 7ff2ca914a
5 changed files with 25 additions and 4 deletions

View File

@@ -1,12 +1,15 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 365
INVENTREE_API_VERSION = 366
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v366 -> 2025-07-09 : https://github.com/inventree/InvenTree/pull/9987
- Adds "category" filter to BomItem API endpoint
v365 -> 2025-07-09 : https://github.com/inventree/InvenTree/pull/9984
- Allow filtering of DataOutput API by "user" field
- Allow individual deletion of DataOutput objects via the API

View File

@@ -1631,10 +1631,24 @@ class BomFilter(rest_filters.FilterSet):
queryset=Part.objects.all(), method='filter_part', label=_('Part')
)
@extend_schema_field(OpenApiTypes.INT)
def filter_part(self, queryset, name, part):
"""Filter the queryset based on the specified part."""
return queryset.filter(part.get_bom_item_filter())
category = rest_filters.ModelChoiceFilter(
queryset=PartCategory.objects.all(),
method='filter_category',
label=_('Category'),
)
@extend_schema_field(OpenApiTypes.INT)
def filter_category(self, queryset, name, category):
"""Filter the queryset based on the specified PartCategory."""
cats = category.get_descendants(include_self=True)
return queryset.filter(sub_part__category__in=cats)
uses = rest_filters.ModelChoiceFilter(
queryset=Part.objects.all(), method='filter_uses', label=_('Uses')
)