mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 14:28:48 +00:00
Raise error if specified quantity is above available quantity
This commit is contained in:
parent
5329e3e56c
commit
11ee8e8369
@ -248,6 +248,11 @@ class StockRemove(StockAdjust):
|
|||||||
|
|
||||||
for item in self.items:
|
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):
|
if item['item'].take_stock(item['quantity'], request.user, notes=self.notes):
|
||||||
n += 1
|
n += 1
|
||||||
|
|
||||||
@ -276,6 +281,11 @@ class StockTransfer(StockAdjust):
|
|||||||
|
|
||||||
for item in self.items:
|
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 quantity is not specified, move the entire stock
|
||||||
if item['quantity'] in [0, None]:
|
if item['quantity'] in [0, None]:
|
||||||
item['quantity'] = item['item'].quantity
|
item['quantity'] = item['item'].quantity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user