mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Allow BOM table to be filtered by "stock available" parameter (#3301)
* Allow BOM table to be filtered by "stock available" parameter * Update API version info * PEP fixes
This commit is contained in:
parent
412fdf246a
commit
cc8238b790
@ -7,8 +7,12 @@ INVENTREE_API_VERSION = 61
|
|||||||
"""
|
"""
|
||||||
Increment this API version number whenever there is a significant change to the API that any clients need to know about
|
Increment this API version number whenever there is a significant change to the API that any clients need to know about
|
||||||
|
|
||||||
|
v63 -> 2022-07-06 : https://github.com/inventree/InvenTree/pull/3301
|
||||||
|
- Allow BOM List API endpoint to be filtered by "available_stock" paramater
|
||||||
|
|
||||||
v62 -> 2022-07-05 : https://github.com/inventree/InvenTree/pull/3296
|
v62 -> 2022-07-05 : https://github.com/inventree/InvenTree/pull/3296
|
||||||
- Allows search on BOM List API endpoint
|
- Allows search on BOM List API endpoint
|
||||||
|
- Allows ordering on BOM List API endpoint
|
||||||
|
|
||||||
v61 -> 2022-06-12 : https://github.com/inventree/InvenTree/pull/3183
|
v61 -> 2022-06-12 : https://github.com/inventree/InvenTree/pull/3183
|
||||||
- Migrate the "Convert Stock Item" form class to use the API
|
- Migrate the "Convert Stock Item" form class to use the API
|
||||||
|
@ -1531,6 +1531,20 @@ class BomFilter(rest_filters.FilterSet):
|
|||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
available_stock = rest_filters.BooleanFilter(label="Has available stock", method="filter_available_stock")
|
||||||
|
|
||||||
|
def filter_available_stock(self, queryset, name, value):
|
||||||
|
"""Filter the queryset based on whether each line item has any available stock"""
|
||||||
|
|
||||||
|
value = str2bool(value)
|
||||||
|
|
||||||
|
if value:
|
||||||
|
queryset = queryset.filter(available_stock__gt=0)
|
||||||
|
else:
|
||||||
|
queryset = queryset.filter(available_stock=0)
|
||||||
|
|
||||||
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
class BomList(ListCreateDestroyAPIView):
|
class BomList(ListCreateDestroyAPIView):
|
||||||
"""API endpoint for accessing a list of BomItem objects.
|
"""API endpoint for accessing a list of BomItem objects.
|
||||||
|
@ -59,6 +59,10 @@ function getAvailableTableFilters(tableKey) {
|
|||||||
type: 'bool',
|
type: 'bool',
|
||||||
title: '{% trans "Assembled Part" %}',
|
title: '{% trans "Assembled Part" %}',
|
||||||
},
|
},
|
||||||
|
available_stock: {
|
||||||
|
type: 'bool',
|
||||||
|
title: '{% trans "Has Available Stock" %}',
|
||||||
|
},
|
||||||
validated: {
|
validated: {
|
||||||
type: 'bool',
|
type: 'bool',
|
||||||
title: '{% trans "Validated" %}',
|
title: '{% trans "Validated" %}',
|
||||||
|
Loading…
Reference in New Issue
Block a user