mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +00:00
Adds framework for API endpoint and serializer to merge stock items
This commit is contained in:
parent
189f836e47
commit
fdf79065a9
@ -180,6 +180,20 @@ class StockAssign(generics.CreateAPIView):
|
|||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
|
class StockMerge(generics.CreateAPIView):
|
||||||
|
"""
|
||||||
|
API endpoint for merging multiple stock items
|
||||||
|
"""
|
||||||
|
|
||||||
|
queryset = StockItem.objects.none()
|
||||||
|
serializer_class = StockSerializers.StockMergeSerializer
|
||||||
|
|
||||||
|
def get_serializer_context(self):
|
||||||
|
ctx = super().get_serializer_context()
|
||||||
|
ctx['request'] = self.request
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
class StockLocationList(generics.ListCreateAPIView):
|
class StockLocationList(generics.ListCreateAPIView):
|
||||||
"""
|
"""
|
||||||
API endpoint for list view of StockLocation objects:
|
API endpoint for list view of StockLocation objects:
|
||||||
@ -1213,6 +1227,7 @@ stock_api_urls = [
|
|||||||
url(r'^remove/', StockRemove.as_view(), name='api-stock-remove'),
|
url(r'^remove/', StockRemove.as_view(), name='api-stock-remove'),
|
||||||
url(r'^transfer/', StockTransfer.as_view(), name='api-stock-transfer'),
|
url(r'^transfer/', StockTransfer.as_view(), name='api-stock-transfer'),
|
||||||
url(r'^assign/', StockAssign.as_view(), name='api-stock-assign'),
|
url(r'^assign/', StockAssign.as_view(), name='api-stock-assign'),
|
||||||
|
url(r'^merge/', StockMerge.as_view(), name='api-stock-merge'),
|
||||||
|
|
||||||
# StockItemAttachment API endpoints
|
# StockItemAttachment API endpoints
|
||||||
url(r'^attachment/', include([
|
url(r'^attachment/', include([
|
||||||
|
@ -674,6 +674,39 @@ class StockAssignmentSerializer(serializers.Serializer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class StockMergeSerializer(serializers.Serializer):
|
||||||
|
"""
|
||||||
|
Serializer for merging two (or more) stock items together
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
fields = [
|
||||||
|
# 'items',
|
||||||
|
'location',
|
||||||
|
]
|
||||||
|
|
||||||
|
location = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=StockLocation.objects.all(),
|
||||||
|
many=False,
|
||||||
|
required=True,
|
||||||
|
allow_null=False,
|
||||||
|
label=_('Location'),
|
||||||
|
help_text=_('Destination stock location'),
|
||||||
|
)
|
||||||
|
|
||||||
|
def validate(self, data):
|
||||||
|
|
||||||
|
data = super().validate(data)
|
||||||
|
|
||||||
|
# TODO: Custom data validation
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
# TODO
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class StockAdjustmentItemSerializer(serializers.Serializer):
|
class StockAdjustmentItemSerializer(serializers.Serializer):
|
||||||
"""
|
"""
|
||||||
Serializer for a single StockItem within a stock adjument request.
|
Serializer for a single StockItem within a stock adjument request.
|
||||||
@ -837,7 +870,7 @@ class StockTransferSerializer(StockAdjustmentSerializer):
|
|||||||
|
|
||||||
def validate(self, data):
|
def validate(self, data):
|
||||||
|
|
||||||
super().validate(data)
|
data = super().validate(data)
|
||||||
|
|
||||||
# TODO: Any specific validation of location field?
|
# TODO: Any specific validation of location field?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user