mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-03 22:08:49 +00:00
Add part queryset filtering to exclude particular ID values
This commit is contained in:
parent
0c60387626
commit
9b00ede61a
@ -814,6 +814,27 @@ class PartList(generics.ListCreateAPIView):
|
|||||||
except (ValueError, Part.DoesNotExist):
|
except (ValueError, Part.DoesNotExist):
|
||||||
pass
|
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 part variant tree?
|
||||||
exclude_tree = params.get('exclude_tree', None)
|
exclude_tree = params.get('exclude_tree', None)
|
||||||
|
|
||||||
|
@ -263,6 +263,12 @@ function bomSubstitutesDialog(bom_item_id, substitutes, options={}) {
|
|||||||
|
|
||||||
var subs = getSubstituteIdValues(opts.modal);
|
var subs = getSubstituteIdValues(opts.modal);
|
||||||
|
|
||||||
|
// Also exclude the "master" part (if provided)
|
||||||
|
if (options.sub_part) {
|
||||||
|
subs.push(options.sub_part);
|
||||||
|
console.log("sub_part:", options.sub_part);
|
||||||
|
}
|
||||||
|
|
||||||
if (subs.length > 0) {
|
if (subs.length > 0) {
|
||||||
query.exclude_id = subs;
|
query.exclude_id = subs;
|
||||||
}
|
}
|
||||||
@ -824,6 +830,7 @@ function loadBomTable(table, options) {
|
|||||||
subs,
|
subs,
|
||||||
{
|
{
|
||||||
table: table,
|
table: table,
|
||||||
|
sub_part: row.sub_part,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user