2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 03:25:42 +00:00

Adds "is_variant" filter for Part API (#9077)

* Adds "is_variant" filter for Part API

* Bump API version
This commit is contained in:
Oliver
2025-02-14 17:08:27 +11:00
committed by GitHub
parent caa0498aa3
commit cca1912220
3 changed files with 18 additions and 1 deletions

View File

@ -1,13 +1,16 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 309
INVENTREE_API_VERSION = 310
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v310 - 2025-02-14 : https://github.com/inventree/InvenTree/pull/9077
- Adds 'is_variant' filter to the Part list API
v309 - 2025-02-02 : https://github.com/inventree/InvenTree/pull/9008
- Bug fixes for the "Part" serializer
- Fixes for data import API endpoints

View File

@ -895,6 +895,14 @@ class PartFilter(rest_filters.FilterSet):
model = Part
fields = ['revision_of']
is_variant = rest_filters.BooleanFilter(
label=_('Is Variant'), method='filter_is_variant'
)
def filter_is_variant(self, queryset, name, value):
"""Filter by whether the Part is a variant or not."""
return queryset.filter(variant_of__isnull=not str2bool(value))
is_revision = rest_filters.BooleanFilter(
label=_('Is Revision'), method='filter_is_revision'
)

View File

@ -269,6 +269,12 @@ function partTableFilters(): TableFilter[] {
description: t`Filter by parts which are templates`,
type: 'boolean'
},
{
name: 'is_variant',
label: t`Is Variant`,
description: t`Filter by parts which are variants`,
type: 'boolean'
},
{
name: 'is_revision',
label: t`Is Revision`,