mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Prevent a Part from both having variants and being a variant of something else
This commit is contained in:
parent
1a2fb9e170
commit
bc778c1451
@ -253,6 +253,15 @@ class Part(models.Model):
|
||||
else:
|
||||
return static('/img/blank_image.png')
|
||||
|
||||
def clean(self):
|
||||
""" Perform cleaning operations for the Part model """
|
||||
|
||||
if self.has_variants and self.variant_of is not None:
|
||||
raise ValidationError({
|
||||
'variant_of': _("Part cannot be a variant of another part if it is already a template"),
|
||||
'has_variants': _("Part cannot be a template part if it is a variant of another part")
|
||||
})
|
||||
|
||||
name = models.CharField(max_length=100, blank=False, help_text='Part name',
|
||||
validators=[validators.validate_part_name]
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user