diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index a98511dc53..c70ef5c21a 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -430,6 +430,17 @@ class PartList(generics.ListCreateAPIView): except (ValueError, Part.DoesNotExist): pass + # Filter by whether the part has an IPN (internal part number) defined + has_ipn = params.get('has_ipn', None) + + if has_ipn is not None: + has_ipn = str2bool(has_ipn) + + if has_ipn: + queryset = queryset.exclude(IPN='') + else: + queryset = queryset.filter(IPN='') + # Filter by whether the BOM has been validated (or not) bom_valid = params.get('bom_valid', None) diff --git a/InvenTree/templates/js/table_filters.html b/InvenTree/templates/js/table_filters.html index 44c4149265..a97d358828 100644 --- a/InvenTree/templates/js/table_filters.html +++ b/InvenTree/templates/js/table_filters.html @@ -173,6 +173,11 @@ function getAvailableTableFilters(tableKey) { title: '{% trans "Include subcategories" %}', description: '{% trans "Include parts in subcategories" %}', }, + has_ipn: { + type: 'bool', + title: '{% trans "Has IPN" %}', + description: '{% trans "Part has internal part number" %}', + }, active: { type: 'bool', title: '{% trans "Active" %}',