2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 19:45:46 +00:00

More test

This commit is contained in:
Oliver Walters
2019-09-08 20:36:51 +10:00
parent 2a203be5cc
commit e4fc44c135
5 changed files with 26 additions and 15 deletions

View File

@ -265,17 +265,9 @@ class Part(models.Model):
def set_category(self, category):
if not type(category) == PartCategory:
raise ValidationError({
'category': _('Invalid object supplied to part.set_category')
})
try:
# Already in this category!
if category == self.category:
return
except PartCategory.DoesNotExist:
pass
# Ignore if the category is already the same
if self.category == category:
return
self.category = category
self.save()