Add filter for supplier part table:

Filter by "active" status
This commit is contained in:
Oliver Walters 2020-10-29 12:50:17 +11:00
parent 60a8ef723b
commit b3ac261746
4 changed files with 21 additions and 0 deletions

View File

@ -131,6 +131,13 @@ class SupplierPartList(generics.ListCreateAPIView):
if part is not None:
queryset = queryset.filter(part=part)
# Filter by 'active' status of the part?
active = params.get('active', None)
if active is not None:
active = str2bool(active)
queryset = queryset.filter(part__active=active)
return queryset
def get_serializer(self, *args, **kwargs):

View File

@ -34,6 +34,9 @@
</div>
</div>
</div>
<div class='filter-list' id='filter-list-supplier-part'>
<!-- Empty div (will be filled out with available BOM filters) -->
</div>
</div>
</div>
{% endif %}

View File

@ -122,6 +122,7 @@ function loadSupplierPartTable(table, url, options) {
$(table).inventreeTable({
url: url,
method: 'get',
original: params,
queryParams: filters,
name: 'supplierparts',
groupBy: false,
@ -135,6 +136,7 @@ function loadSupplierPartTable(table, url, options) {
sortable: true,
field: 'part_detail.full_name',
title: '{% trans "Part" %}',
switchable: false,
formatter: function(value, row, index, field) {
var url = `/part/${row.part}/`;

View File

@ -189,6 +189,15 @@ function getAvailableTableFilters(tableKey) {
};
}
if (tableKey == 'supplier-part') {
return {
active: {
type: 'bool',
title: '{% trans "Active parts" %}',
}
};
}
// Filters for the "Parts" table
if (tableKey == "parts") {
return {