mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +00:00 
			
		
		
		
	Build table fix (#7940)
* Remove sales order filter restriction * Formalize "ancestor" filter * Bump API version
This commit is contained in:
		| @@ -1,13 +1,16 @@ | ||||
| """InvenTree API version information.""" | ||||
|  | ||||
| # InvenTree API version | ||||
| INVENTREE_API_VERSION = 242 | ||||
| INVENTREE_API_VERSION = 243 | ||||
|  | ||||
| """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" | ||||
|  | ||||
|  | ||||
| INVENTREE_API_TEXT = """ | ||||
|  | ||||
| v243 - 2024-08-21 : https://github.com/inventree/InvenTree/pull/7940 | ||||
|     - Expose "ancestor" filter to the BuildOrder API | ||||
|  | ||||
| v242 - 2024-08-20 : https://github.com/inventree/InvenTree/pull/7932 | ||||
|     - Adds "level" attribute to BuildOrder serializer | ||||
|     - Allow ordering of BuildOrder API by "level" attribute | ||||
|   | ||||
| @@ -48,34 +48,23 @@ class BuildFilter(rest_filters.FilterSet): | ||||
|             return queryset.filter(status__in=BuildStatusGroups.ACTIVE_CODES) | ||||
|         return queryset.exclude(status__in=BuildStatusGroups.ACTIVE_CODES) | ||||
|  | ||||
|     cascade = rest_filters.BooleanFilter(label=_('Cascade'), method='filter_cascade') | ||||
|  | ||||
|     def filter_cascade(self, queryset, name, value): | ||||
|         """Filter by whether or not the build is a 'cascade' build. | ||||
|  | ||||
|         Note: this only applies when the 'parent' field filter is specified. | ||||
|         """ | ||||
|  | ||||
|         # No filtering here, see 'filter_parent' | ||||
|         return queryset | ||||
|  | ||||
|     parent = rest_filters.ModelChoiceFilter( | ||||
|         queryset=Build.objects.all(), | ||||
|         label=_('Parent Build'), | ||||
|         field_name='parent', | ||||
|         method='filter_parent' | ||||
|     ) | ||||
|  | ||||
|     def filter_parent(self, queryset, name, parent): | ||||
|     ancestor = rest_filters.ModelChoiceFilter( | ||||
|         queryset=Build.objects.all(), | ||||
|         label=_('Ancestor Build'), | ||||
|         method='filter_ancestor' | ||||
|     ) | ||||
|  | ||||
|     def filter_ancestor(self, queryset, name, parent): | ||||
|         """Filter by 'parent' build order.""" | ||||
|  | ||||
|         cascade = str2bool(self.data.get('cascade', False)) | ||||
|  | ||||
|         if cascade: | ||||
|             builds = parent.get_descendants(include_self=False) | ||||
|             return queryset.filter(pk__in=[b.pk for b in builds]) | ||||
|  | ||||
|         return queryset.filter(parent=parent) | ||||
|         builds = parent.get_descendants(include_self=False) | ||||
|         return queryset.filter(pk__in=[b.pk for b in builds]) | ||||
|  | ||||
|     overdue = rest_filters.BooleanFilter(label='Build is overdue', method='filter_overdue') | ||||
|  | ||||
| @@ -252,22 +241,6 @@ class BuildList(DataExportViewMixin, BuildMixin, ListCreateAPI): | ||||
|             except (ValueError, Build.DoesNotExist): | ||||
|                 pass | ||||
|  | ||||
|         # Filter by "ancestor" builds | ||||
|         ancestor = params.get('ancestor', None) | ||||
|  | ||||
|         if ancestor is not None: | ||||
|             try: | ||||
|                 ancestor = Build.objects.get(pk=ancestor) | ||||
|  | ||||
|                 descendants = ancestor.get_descendants(include_self=True) | ||||
|  | ||||
|                 queryset = queryset.filter( | ||||
|                     parent__pk__in=[b.pk for b in descendants] | ||||
|                 ) | ||||
|  | ||||
|             except (ValueError, Build.DoesNotExist): | ||||
|                 pass | ||||
|  | ||||
|         # Filter by 'date range' | ||||
|         min_date = params.get('min_date', None) | ||||
|         max_date = params.get('max_date', None) | ||||
|   | ||||
| @@ -13,7 +13,6 @@ import { useCreateApiFormModal } from '../../hooks/UseForm'; | ||||
| import { useTable } from '../../hooks/UseTable'; | ||||
| import { apiUrl } from '../../states/ApiState'; | ||||
| import { useUserState } from '../../states/UserState'; | ||||
| import { TableColumn } from '../Column'; | ||||
| import { | ||||
|   CreationDateColumn, | ||||
|   DateColumn, | ||||
| @@ -110,13 +109,6 @@ export function BuildOrderTable({ | ||||
|         label: t`Active`, | ||||
|         description: t`Show active orders` | ||||
|       }, | ||||
|       { | ||||
|         name: 'cascade', | ||||
|         type: 'boolean', | ||||
|         label: t`Cascade`, | ||||
|         description: t`Display recursive child orders`, | ||||
|         active: !!parentBuildId | ||||
|       }, | ||||
|       { | ||||
|         name: 'status', | ||||
|         label: t`Status`, | ||||
| @@ -201,8 +193,7 @@ export function BuildOrderTable({ | ||||
|         props={{ | ||||
|           params: { | ||||
|             part: partId, | ||||
|             sales_order: salesOrderId, | ||||
|             parent: parentBuildId, | ||||
|             ancestor: parentBuildId, | ||||
|             part_detail: true | ||||
|           }, | ||||
|           tableActions: tableActions, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user