mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-24 15:50:54 +00:00
Fix error in BomItem creation
This commit is contained in:
@ -858,6 +858,8 @@ class BomItem(models.Model):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# A part cannot refer to itself in its BOM
|
# A part cannot refer to itself in its BOM
|
||||||
|
try:
|
||||||
|
if self.sub_part is not None and self.part is not None:
|
||||||
if self.part == self.sub_part:
|
if self.part == self.sub_part:
|
||||||
raise ValidationError({'sub_part': _('Part cannot be added to its own Bill of Materials')})
|
raise ValidationError({'sub_part': _('Part cannot be added to its own Bill of Materials')})
|
||||||
|
|
||||||
@ -866,6 +868,10 @@ class BomItem(models.Model):
|
|||||||
if self.part == item.sub_part:
|
if self.part == item.sub_part:
|
||||||
raise ValidationError({'sub_part': _("Part '{p1}' is used in BOM for '{p2}' (recursive)".format(p1=str(self.part), p2=str(self.sub_part)))})
|
raise ValidationError({'sub_part': _("Part '{p1}' is used in BOM for '{p2}' (recursive)".format(p1=str(self.part), p2=str(self.sub_part)))})
|
||||||
|
|
||||||
|
except Part.DoesNotExist:
|
||||||
|
# A blank Part will be caught elsewhere
|
||||||
|
pass
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "BOM Item"
|
verbose_name = "BOM Item"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user