Raise error if specified quantity is above available quantity

This commit is contained in:
Oliver 2021-07-12 19:58:39 +10:00
parent 5329e3e56c
commit 11ee8e8369

View File

@ -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