mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-12 10:05:39 +00:00
Fix parent error when deleting category
- Any child categories have their parent set to the parent of the deleted category
This commit is contained in:
@ -16,6 +16,9 @@ class PartCategory(InvenTreeTree):
|
||||
""" PartCategory provides hierarchical organization of Part objects.
|
||||
"""
|
||||
|
||||
def get_absolute_url(self):
|
||||
return '/part/category/{id}/'.format(id=self.id)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Part Category"
|
||||
verbose_name_plural = "Part Categories"
|
||||
@ -48,6 +51,11 @@ def before_delete_part_category(sender, instance, using, **kwargs):
|
||||
part.category = instance.parent
|
||||
part.save()
|
||||
|
||||
# Update each child category
|
||||
for child in instance.children.all():
|
||||
child.parent = instance.parent
|
||||
child.save()
|
||||
|
||||
|
||||
# Function to automatically rename a part image on upload
|
||||
# Format: part_pk.<img>
|
||||
|
Reference in New Issue
Block a user