diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index dccc2f9ac1..4dd9841332 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -814,6 +814,27 @@ class PartList(generics.ListCreateAPIView): except (ValueError, Part.DoesNotExist): pass + # Exclude specific part ID values? + exclude_id = [] + + for key in ['exclude_id', 'exclude_id[]']: + if key in params: + exclude_id += params.getlist(key, []) + + if exclude_id: + + id_values = [] + + for val in exclude_id: + try: + # pk values must be integer castable + val = int(val) + id_values.append(val) + except ValueError: + pass + + queryset = queryset.exclude(pk__in=id_values) + # Exclude part variant tree? exclude_tree = params.get('exclude_tree', None) diff --git a/InvenTree/templates/js/translated/bom.js b/InvenTree/templates/js/translated/bom.js index 7cab63153b..89ae428bcd 100644 --- a/InvenTree/templates/js/translated/bom.js +++ b/InvenTree/templates/js/translated/bom.js @@ -157,6 +157,19 @@ function bomSubstitutesDialog(bom_item_id, substitutes, options={}) { } } + // Extract a list of all existing "substitute" id values + function getSubstituteIdValues(modal) { + + var id_values = []; + + $(modal).find('.substitute-row').each(function(el) { + var part = $(this).attr('part'); + id_values.push(part); + }); + + return id_values; + } + function renderSubstituteRow(substitute) { var pk = substitute.pk; @@ -171,7 +184,7 @@ function bomSubstitutesDialog(bom_item_id, substitutes, options={}) { // Render a single row var html = ` -