mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1797 from SchrodingersGat/bom-validation-fix
Add numerical validation step for BomItem
This commit is contained in:
commit
d9c2d061cc
@ -30,7 +30,7 @@ from mptt.models import TreeForeignKey, MPTTModel
|
||||
|
||||
from stdimage.models import StdImageField
|
||||
|
||||
from decimal import Decimal
|
||||
from decimal import Decimal, InvalidOperation
|
||||
from datetime import datetime
|
||||
from rapidfuzz import fuzz
|
||||
import hashlib
|
||||
@ -2418,6 +2418,15 @@ class BomItem(models.Model):
|
||||
- If the "sub_part" is trackable, then the "part" must be trackable too!
|
||||
"""
|
||||
|
||||
super().clean()
|
||||
|
||||
try:
|
||||
self.quantity = Decimal(self.quantity)
|
||||
except InvalidOperation:
|
||||
raise ValidationError({
|
||||
'quantity': _('Must be a valid number')
|
||||
})
|
||||
|
||||
try:
|
||||
# Check for circular BOM references
|
||||
if self.sub_part:
|
||||
|
Loading…
Reference in New Issue
Block a user