mirror of
https://github.com/inventree/InvenTree.git
synced 2025-09-14 06:31:27 +00:00
[UI] Location filter (#9939)
* Filter incomplete outputs by location * Filter build allocated stock by location * Filter sales order allocations by location * Bump API version * Fix API version * Fix annotations
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
"""InvenTree API version information."""
|
||||
|
||||
# InvenTree API version
|
||||
INVENTREE_API_VERSION = 361
|
||||
INVENTREE_API_VERSION = 362
|
||||
|
||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||
|
||||
INVENTREE_API_TEXT = """
|
||||
|
||||
v362 -> 2025-07-02 : https://github.com/inventree/InvenTree/pull/9939
|
||||
- Allow filtering of BuildItem API by "location" of StockItem
|
||||
- Allow filtering of SalesOrderAllocation API by "location" of StockItem
|
||||
|
||||
v361 -> 2025-07-03 : https://github.com/inventree/InvenTree/pull/9944
|
||||
- Enable SalesOrderAllocation list to be filtered by part IPN value
|
||||
- Enable SalesOrderAllocation list to be ordered by part MPN value
|
||||
|
@@ -16,6 +16,7 @@ from rest_framework.response import Response
|
||||
import build.serializers
|
||||
import common.models
|
||||
import part.models as part_models
|
||||
import stock.models as stock_models
|
||||
import stock.serializers
|
||||
from build.models import Build, BuildItem, BuildLine
|
||||
from build.status_codes import BuildStatus, BuildStatusGroups
|
||||
@@ -830,6 +831,18 @@ class BuildItemFilter(rest_filters.FilterSet):
|
||||
return queryset.exclude(install_into=None)
|
||||
return queryset.filter(install_into=None)
|
||||
|
||||
location = rest_filters.ModelChoiceFilter(
|
||||
queryset=stock_models.StockLocation.objects.all(),
|
||||
label=_('Location'),
|
||||
method='filter_location',
|
||||
)
|
||||
|
||||
@extend_schema_field(serializers.IntegerField(help_text=_('Location')))
|
||||
def filter_location(self, queryset, name, location):
|
||||
"""Filter the queryset based on the specified location."""
|
||||
locations = location.get_descendants(include_self=True)
|
||||
return queryset.filter(stock_item__location__in=locations)
|
||||
|
||||
|
||||
class BuildItemList(DataExportViewMixin, BulkDeleteMixin, ListCreateAPI):
|
||||
"""API endpoint for accessing a list of BuildItem objects.
|
||||
|
@@ -23,6 +23,7 @@ import build.models
|
||||
import common.models
|
||||
import common.settings
|
||||
import company.models
|
||||
import stock.models as stock_models
|
||||
from data_exporter.mixins import DataExportViewMixin
|
||||
from generic.states.api import StatusView
|
||||
from InvenTree.api import BulkUpdateMixin, ListCreateDestroyAPIView, MetadataView
|
||||
@@ -1178,6 +1179,20 @@ class SalesOrderAllocationFilter(rest_filters.FilterSet):
|
||||
return queryset.exclude(shipment=None)
|
||||
return queryset.filter(shipment=None)
|
||||
|
||||
location = rest_filters.ModelChoiceFilter(
|
||||
queryset=stock_models.StockLocation.objects.all(),
|
||||
label=_('Location'),
|
||||
method='filter_location',
|
||||
)
|
||||
|
||||
@extend_schema_field(
|
||||
rest_framework.serializers.IntegerField(help_text=_('Location'))
|
||||
)
|
||||
def filter_location(self, queryset, name, location):
|
||||
"""Filter by the location of the allocated StockItem."""
|
||||
locations = location.get_descendants(include_self=True)
|
||||
return queryset.filter(item__location__in=locations)
|
||||
|
||||
|
||||
class SalesOrderAllocationMixin:
|
||||
"""Mixin class for SalesOrderAllocation endpoints."""
|
||||
|
Reference in New Issue
Block a user