diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 21cb0989d5..c7d92e0a7b 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -248,6 +248,11 @@ class StockRemove(StockAdjust): for item in self.items: + if item['quantity'] > item['item'].quantity: + raise ValidationError({ + item['item'].pk: [_('Specified quantity exceeds stock quantity')] + }) + if item['item'].take_stock(item['quantity'], request.user, notes=self.notes): n += 1 @@ -276,6 +281,11 @@ class StockTransfer(StockAdjust): for item in self.items: + if item['quantity'] > item['item'].quantity: + raise ValidationError({ + item['item'].pk: [_('Specified quantity exceeds stock quantity')] + }) + # If quantity is not specified, move the entire stock if item['quantity'] in [0, None]: item['quantity'] = item['item'].quantity