mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-16 20:15:44 +00:00
Include location detail in build output table (#8923)
* Include location detail in build output table * Raise validation error if trying to split an in-production item
This commit is contained in:
@ -1985,9 +1985,18 @@ class StockItem(
|
||||
Returns:
|
||||
The new StockItem object
|
||||
|
||||
Raises:
|
||||
ValidationError: If the stock item cannot be split
|
||||
|
||||
- The provided quantity will be subtracted from this item and given to the new one.
|
||||
- The new item will have a different StockItem ID, while this will remain the same.
|
||||
"""
|
||||
# Run initial checks to test if the stock item can actually be "split"
|
||||
|
||||
# Cannot split a stock item which is in production
|
||||
if self.is_building:
|
||||
raise ValidationError(_('Stock item is currently in production'))
|
||||
|
||||
notes = kwargs.get('notes', '')
|
||||
|
||||
# Do not split a serialized part
|
||||
|
@ -1565,18 +1565,18 @@ class StockAdjustmentItemSerializer(serializers.Serializer):
|
||||
help_text=_('StockItem primary key value'),
|
||||
)
|
||||
|
||||
def validate_pk(self, pk):
|
||||
def validate_pk(self, stock_item: StockItem) -> StockItem:
|
||||
"""Ensure the stock item is valid."""
|
||||
allow_out_of_stock_transfer = get_global_setting(
|
||||
'STOCK_ALLOW_OUT_OF_STOCK_TRANSFER', backup_value=False, cache=False
|
||||
)
|
||||
|
||||
if not allow_out_of_stock_transfer and not pk.is_in_stock(
|
||||
if not allow_out_of_stock_transfer and not stock_item.is_in_stock(
|
||||
check_status=False, check_quantity=False
|
||||
):
|
||||
raise ValidationError(_('Stock item is not in stock'))
|
||||
|
||||
return pk
|
||||
return stock_item
|
||||
|
||||
quantity = serializers.DecimalField(
|
||||
max_digits=15, decimal_places=5, min_value=Decimal(0), required=True
|
||||
|
Reference in New Issue
Block a user