mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 13:28:49 +00:00
Add "exclude_location" to build order auto-allocation
This commit is contained in:
parent
927e206e14
commit
4191a043b2
@ -12,11 +12,14 @@ import common.models
|
|||||||
INVENTREE_SW_VERSION = "0.7.0 dev"
|
INVENTREE_SW_VERSION = "0.7.0 dev"
|
||||||
|
|
||||||
# InvenTree API version
|
# InvenTree API version
|
||||||
INVENTREE_API_VERSION = 29
|
INVENTREE_API_VERSION = 30
|
||||||
|
|
||||||
"""
|
"""
|
||||||
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
|
||||||
|
|
||||||
|
v30 -> 2022-03-09
|
||||||
|
- Adds "exclude_location" field to BuildAutoAllocation API endpoint
|
||||||
|
|
||||||
v29 -> 2022-03-08
|
v29 -> 2022-03-08
|
||||||
- Adds "scheduling" endpoint for predicted stock scheduling information
|
- Adds "scheduling" endpoint for predicted stock scheduling information
|
||||||
|
|
||||||
|
@ -842,6 +842,7 @@ class Build(MPTTModel, ReferenceIndexingMixin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
location = kwargs.get('location', None)
|
location = kwargs.get('location', None)
|
||||||
|
exclude_location = kwargs.get('exclude_location', None)
|
||||||
interchangeable = kwargs.get('interchangeable', False)
|
interchangeable = kwargs.get('interchangeable', False)
|
||||||
substitutes = kwargs.get('substitutes', True)
|
substitutes = kwargs.get('substitutes', True)
|
||||||
|
|
||||||
@ -875,6 +876,11 @@ class Build(MPTTModel, ReferenceIndexingMixin):
|
|||||||
sublocations = location.get_descendants(include_self=True)
|
sublocations = location.get_descendants(include_self=True)
|
||||||
available_stock = available_stock.filter(location__in=[loc for loc in sublocations])
|
available_stock = available_stock.filter(location__in=[loc for loc in sublocations])
|
||||||
|
|
||||||
|
if exclude_location:
|
||||||
|
# Exclude any stock items from the provided location
|
||||||
|
sublocations = exclude_location.get_descendants(include_self=True)
|
||||||
|
available_stock = available_stock.exclude(location__in=[loc for loc in sublocations])
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Next, we sort the available stock items with the following priority:
|
Next, we sort the available stock items with the following priority:
|
||||||
1. Direct part matches (+1)
|
1. Direct part matches (+1)
|
||||||
|
@ -717,6 +717,7 @@ class BuildAutoAllocationSerializer(serializers.Serializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
fields = [
|
fields = [
|
||||||
'location',
|
'location',
|
||||||
|
'exclude_location',
|
||||||
'interchangeable',
|
'interchangeable',
|
||||||
'substitutes',
|
'substitutes',
|
||||||
]
|
]
|
||||||
@ -730,6 +731,15 @@ class BuildAutoAllocationSerializer(serializers.Serializer):
|
|||||||
help_text=_('Stock location where parts are to be sourced (leave blank to take from any location)'),
|
help_text=_('Stock location where parts are to be sourced (leave blank to take from any location)'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
exclude_location = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=StockLocation.objects.all(),
|
||||||
|
many=False,
|
||||||
|
allow_null=True,
|
||||||
|
required=False,
|
||||||
|
label=_('Exclude Location'),
|
||||||
|
help_text=_('Exclude stock items from this selected location'),
|
||||||
|
)
|
||||||
|
|
||||||
interchangeable = serializers.BooleanField(
|
interchangeable = serializers.BooleanField(
|
||||||
default=False,
|
default=False,
|
||||||
label=_('Interchangeable Stock'),
|
label=_('Interchangeable Stock'),
|
||||||
@ -750,6 +760,7 @@ class BuildAutoAllocationSerializer(serializers.Serializer):
|
|||||||
|
|
||||||
build.auto_allocate_stock(
|
build.auto_allocate_stock(
|
||||||
location=data.get('location', None),
|
location=data.get('location', None),
|
||||||
|
exclude_location=data.get('exclude_location', None),
|
||||||
interchangeable=data['interchangeable'],
|
interchangeable=data['interchangeable'],
|
||||||
substitutes=data['substitutes'],
|
substitutes=data['substitutes'],
|
||||||
)
|
)
|
||||||
|
@ -1876,6 +1876,7 @@ function autoAllocateStockToBuild(build_id, bom_items=[], options={}) {
|
|||||||
location: {
|
location: {
|
||||||
value: options.location,
|
value: options.location,
|
||||||
},
|
},
|
||||||
|
exclude_location: {},
|
||||||
interchangeable: {
|
interchangeable: {
|
||||||
value: true,
|
value: true,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user