Skip to content

Commit

Permalink
Merge branch 'master' into setting-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat committed Feb 14, 2025
2 parents ffc8e30 + cca1912 commit d40af69
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/backend/InvenTree/InvenTree/api_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
v311 - 2025-02-14 : https://github.com/inventree/InvenTree/pull/9076
- Adds "model_filters" attribute to settings API
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
Expand Down
8 changes: 8 additions & 0 deletions src/backend/InvenTree/part/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,14 @@ class Meta:
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'
)
Expand Down
6 changes: 6 additions & 0 deletions src/frontend/src/tables/part/PartTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down

0 comments on commit d40af69

Please sign in to comment.