mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix for BomItem clean function
Handle the case where the sub_part does not exist
This commit is contained in:
parent
73259c0bcb
commit
af9b88de11
@ -1885,8 +1885,12 @@ 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!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# If the sub_part is 'trackable' then the 'quantity' field must be an integer
|
|
||||||
try:
|
try:
|
||||||
|
# Check for circular BOM references
|
||||||
|
if self.sub_part:
|
||||||
|
self.sub_part.checkAddToBOM(self.part)
|
||||||
|
|
||||||
|
# If the sub_part is 'trackable' then the 'quantity' field must be an integer
|
||||||
if self.sub_part.trackable:
|
if self.sub_part.trackable:
|
||||||
if not self.quantity == int(self.quantity):
|
if not self.quantity == int(self.quantity):
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
@ -1898,12 +1902,11 @@ class BomItem(models.Model):
|
|||||||
self.part.trackable = True
|
self.part.trackable = True
|
||||||
self.part.clean()
|
self.part.clean()
|
||||||
self.part.save()
|
self.part.save()
|
||||||
|
else:
|
||||||
|
raise ValidationError({'sub_part': _('Sub part must be specified')})
|
||||||
except Part.DoesNotExist:
|
except Part.DoesNotExist:
|
||||||
pass
|
raise ValidationError({'sub_part': _('Sub part must be specified')})
|
||||||
|
|
||||||
# Check for circular BOM references
|
|
||||||
self.sub_part.checkAddToBOM(self.part)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("BOM Item")
|
verbose_name = _("BOM Item")
|
||||||
|
Loading…
Reference in New Issue
Block a user