mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
Update definition for StockItemAllocation model
- Limit foreignkey choices - Error checking - Check if a StockItem is over-allocated - Fix API serialization and filtering
This commit is contained in:
@ -393,6 +393,15 @@ class BuildItem(models.Model):
|
||||
q=self.stock_item.quantity
|
||||
))]
|
||||
|
||||
if self.stock_item.quantity - self.stock_item.allocation_count() < self.quantity:
|
||||
errors['quantity'] = _('StockItem is over-allocated')
|
||||
|
||||
if self.quantity <= 0:
|
||||
errors['quantity'] = _('Allocation quantity must be greater than zero')
|
||||
|
||||
if self.stock_item.serial and not self.quantity == 1:
|
||||
errors['quantity'] = _('Quantity must be 1 for serialized stock')
|
||||
|
||||
except StockItem.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user