mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 21:16:46 +00:00
Consumed filter (#8574)
* Add API filter for 'consumed' status * Add filter to table * Bump API vession
This commit is contained in:
parent
a48d23b161
commit
28ea275d1a
@ -1,13 +1,16 @@
|
|||||||
"""InvenTree API version information."""
|
"""InvenTree API version information."""
|
||||||
|
|
||||||
# InvenTree API version
|
# InvenTree API version
|
||||||
INVENTREE_API_VERSION = 287
|
INVENTREE_API_VERSION = 288
|
||||||
|
|
||||||
"""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."""
|
||||||
|
|
||||||
|
|
||||||
INVENTREE_API_TEXT = """
|
INVENTREE_API_TEXT = """
|
||||||
|
|
||||||
|
v288 - 2024-11-27 : https://github.com/inventree/InvenTree/pull/8574
|
||||||
|
- Adds "consumed" filter to StockItem API
|
||||||
|
|
||||||
v287 - 2024-11-27 : https://github.com/inventree/InvenTree/pull/8571
|
v287 - 2024-11-27 : https://github.com/inventree/InvenTree/pull/8571
|
||||||
- Adds ability to set stock status when returning items from a customer
|
- Adds ability to set stock status when returning items from a customer
|
||||||
|
|
||||||
|
@ -524,6 +524,7 @@ class StockFilter(rest_filters.FilterSet):
|
|||||||
field_name='part__name',
|
field_name='part__name',
|
||||||
lookup_expr='iexact',
|
lookup_expr='iexact',
|
||||||
)
|
)
|
||||||
|
|
||||||
name_contains = rest_filters.CharFilter(
|
name_contains = rest_filters.CharFilter(
|
||||||
label=_('Part name contains (case insensitive)'),
|
label=_('Part name contains (case insensitive)'),
|
||||||
field_name='part__name',
|
field_name='part__name',
|
||||||
@ -540,11 +541,13 @@ class StockFilter(rest_filters.FilterSet):
|
|||||||
field_name='part__IPN',
|
field_name='part__IPN',
|
||||||
lookup_expr='iexact',
|
lookup_expr='iexact',
|
||||||
)
|
)
|
||||||
|
|
||||||
IPN_contains = rest_filters.CharFilter(
|
IPN_contains = rest_filters.CharFilter(
|
||||||
label=_('Part IPN contains (case insensitive)'),
|
label=_('Part IPN contains (case insensitive)'),
|
||||||
field_name='part__IPN',
|
field_name='part__IPN',
|
||||||
lookup_expr='icontains',
|
lookup_expr='icontains',
|
||||||
)
|
)
|
||||||
|
|
||||||
IPN_regex = rest_filters.CharFilter(
|
IPN_regex = rest_filters.CharFilter(
|
||||||
label=_('Part IPN (regex)'), field_name='part__IPN', lookup_expr='iregex'
|
label=_('Part IPN (regex)'), field_name='part__IPN', lookup_expr='iregex'
|
||||||
)
|
)
|
||||||
@ -553,12 +556,14 @@ class StockFilter(rest_filters.FilterSet):
|
|||||||
assembly = rest_filters.BooleanFilter(
|
assembly = rest_filters.BooleanFilter(
|
||||||
label=_('Assembly'), field_name='part__assembly'
|
label=_('Assembly'), field_name='part__assembly'
|
||||||
)
|
)
|
||||||
|
|
||||||
active = rest_filters.BooleanFilter(label=_('Active'), field_name='part__active')
|
active = rest_filters.BooleanFilter(label=_('Active'), field_name='part__active')
|
||||||
salable = rest_filters.BooleanFilter(label=_('Salable'), field_name='part__salable')
|
salable = rest_filters.BooleanFilter(label=_('Salable'), field_name='part__salable')
|
||||||
|
|
||||||
min_stock = rest_filters.NumberFilter(
|
min_stock = rest_filters.NumberFilter(
|
||||||
label=_('Minimum stock'), field_name='quantity', lookup_expr='gte'
|
label=_('Minimum stock'), field_name='quantity', lookup_expr='gte'
|
||||||
)
|
)
|
||||||
|
|
||||||
max_stock = rest_filters.NumberFilter(
|
max_stock = rest_filters.NumberFilter(
|
||||||
label=_('Maximum stock'), field_name='quantity', lookup_expr='lte'
|
label=_('Maximum stock'), field_name='quantity', lookup_expr='lte'
|
||||||
)
|
)
|
||||||
@ -695,8 +700,18 @@ class StockFilter(rest_filters.FilterSet):
|
|||||||
|
|
||||||
return queryset.filter(q_batch).filter(q_serial).distinct()
|
return queryset.filter(q_batch).filter(q_serial).distinct()
|
||||||
|
|
||||||
|
consumed = rest_filters.BooleanFilter(
|
||||||
|
label=_('Consumed by Build Order'), method='filter_consumed'
|
||||||
|
)
|
||||||
|
|
||||||
|
def filter_consumed(self, queryset, name, value):
|
||||||
|
"""Filter by whether the stock item has been consumed by a build order."""
|
||||||
|
if str2bool(value):
|
||||||
|
return queryset.filter(consumed_by__isnull=False)
|
||||||
|
return queryset.filter(consumed_by__isnull=True)
|
||||||
|
|
||||||
installed = rest_filters.BooleanFilter(
|
installed = rest_filters.BooleanFilter(
|
||||||
label='Installed in other stock item', method='filter_installed'
|
label=_('Installed in other stock item'), method='filter_installed'
|
||||||
)
|
)
|
||||||
|
|
||||||
def filter_installed(self, queryset, name, value):
|
def filter_installed(self, queryset, name, value):
|
||||||
|
@ -343,6 +343,11 @@ function stockItemTableFilters({
|
|||||||
label: t`Include Variants`,
|
label: t`Include Variants`,
|
||||||
description: t`Include stock items for variant parts`
|
description: t`Include stock items for variant parts`
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'consumed',
|
||||||
|
label: t`Consumed`,
|
||||||
|
description: t`Show items which have been consumed by a build order`
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'installed',
|
name: 'installed',
|
||||||
label: t`Installed`,
|
label: t`Installed`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user