Fix for issue 6442 (#6443)

- Add null option to status field for stock adjustment
- Prevent stock adjustments from setting status to OK
This commit is contained in:
Oliver 2024-02-07 20:11:46 +11:00 committed by GitHub
parent fdd70263ea
commit edd6f25411
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1193,6 +1193,14 @@ class StockMergeSerializer(serializers.Serializer):
)
def stock_item_adjust_status_options():
"""Return a custom set of options for the StockItem status adjustment field.
In particular, include a Null option for the status field.
"""
return [(None, _('No Change'))] + InvenTree.status_codes.StockStatus.items()
class StockAdjustmentItemSerializer(serializers.Serializer):
"""Serializer for a single StockItem within a stock adjument request.
@ -1235,8 +1243,8 @@ class StockAdjustmentItemSerializer(serializers.Serializer):
)
status = serializers.ChoiceField(
choices=InvenTree.status_codes.StockStatus.items(),
default=InvenTree.status_codes.StockStatus.OK.value,
choices=stock_item_adjust_status_options(),
default=None,
label=_('Status'),
help_text=_('Stock item status code'),
required=False,
@ -1373,8 +1381,8 @@ class StockTransferSerializer(StockAdjustmentSerializer):
kwargs = {}
for field_name in StockItem.optional_transfer_fields():
if field_name in item:
kwargs[field_name] = item[field_name]
if field_value := item.get(field_name, None):
kwargs[field_name] = field_value
stock_item.move(
location, notes, request.user, quantity=quantity, **kwargs