mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add numerical validation step for BomItem
This commit is contained in:
parent
f6d5bd4ed8
commit
bf2774eb21
@ -30,7 +30,7 @@ from mptt.models import TreeForeignKey, MPTTModel
|
|||||||
|
|
||||||
from stdimage.models import StdImageField
|
from stdimage.models import StdImageField
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal, InvalidOperation
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from rapidfuzz import fuzz
|
from rapidfuzz import fuzz
|
||||||
import hashlib
|
import hashlib
|
||||||
@ -2418,6 +2418,15 @@ class BomItem(models.Model):
|
|||||||
- If the "sub_part" is trackable, then the "part" must be trackable too!
|
- 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:
|
try:
|
||||||
# Check for circular BOM references
|
# Check for circular BOM references
|
||||||
if self.sub_part:
|
if self.sub_part:
|
||||||
|
Loading…
Reference in New Issue
Block a user