From 5f3816212f4581966868ee660565ec46680440d8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 29 May 2020 12:40:40 +1000 Subject: [PATCH] template parts are now allowed to be variants - Do not throw an error here! --- InvenTree/part/models.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 359d0a1aa2..0e086032b4 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -262,6 +262,9 @@ class Part(MPTTModel): if n_refs == 0: previous.image.delete(save=False) + self.clean() + self.validate_unique() + super().save(*args, **kwargs) def __str__(self): @@ -433,11 +436,7 @@ class Part(MPTTModel): def clean(self): """ Perform cleaning operations for the Part model """ - if self.is_template and self.variant_of is not None: - 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"), - }) + super().clean() name = models.CharField(max_length=100, blank=False, help_text=_('Part name'),