2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 12:05:53 +00:00

Set part category for multiple parts at once

This commit is contained in:
Oliver Walters
2019-06-25 19:15:39 +10:00
parent ea44f28bc7
commit d6fcf85cd2
7 changed files with 181 additions and 2 deletions

View File

@ -251,6 +251,23 @@ class Part(models.Model):
return ' | '.join(elements)
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
self.category = category
self.save()
def get_absolute_url(self):
""" Return the web URL for viewing this part """
return reverse('part-detail', kwargs={'pk': self.id})