mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +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:
		| @@ -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 | ||||
|   | ||||
| @@ -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') | ||||
|     ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user