mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #844 from SchrodingersGat/part-validation-fixes
template parts are now allowed to be variants
This commit is contained in:
commit
55bfdc000b
@ -262,6 +262,9 @@ class Part(MPTTModel):
|
|||||||
if n_refs == 0:
|
if n_refs == 0:
|
||||||
previous.image.delete(save=False)
|
previous.image.delete(save=False)
|
||||||
|
|
||||||
|
self.clean()
|
||||||
|
self.validate_unique()
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -433,11 +436,7 @@ class Part(MPTTModel):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
""" Perform cleaning operations for the Part model """
|
""" Perform cleaning operations for the Part model """
|
||||||
|
|
||||||
if self.is_template and self.variant_of is not None:
|
super().clean()
|
||||||
raise ValidationError({
|
|
||||||
'is_template': _("Part cannot be a template part if it is a variant of another part"),
|
|
||||||
'variant_of': _("Part cannot be a variant of another part if it is already a template"),
|
|
||||||
})
|
|
||||||
|
|
||||||
name = models.CharField(max_length=100, blank=False,
|
name = models.CharField(max_length=100, blank=False,
|
||||||
help_text=_('Part name'),
|
help_text=_('Part name'),
|
||||||
|
Loading…
Reference in New Issue
Block a user