2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 05:46:34 +00:00

Catch recursive tree error for part / variant relationship

This commit is contained in:
Oliver
2021-07-21 21:10:31 +10:00
parent dad9239a1c
commit df48df8119
2 changed files with 13 additions and 1 deletions

View File

@ -27,6 +27,7 @@ from markdownx.models import MarkdownxField
from django_cleanup import cleanup
from mptt.models import TreeForeignKey, MPTTModel
from mptt.exceptions import InvalidMove
from mptt.managers import TreeManager
from stdimage.models import StdImageField
@ -426,7 +427,12 @@ class Part(MPTTModel):
self.full_clean()
super().save(*args, **kwargs)
try:
super().save(*args, **kwargs)
except InvalidMove:
raise ValidationError({
'variant_of': _('Invalid choice for parent part'),
})
if add_category_templates:
# Get part category