mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Replace a recursive function
This commit is contained in:
parent
0d6a3d3b28
commit
a5189b8f3f
@ -382,13 +382,11 @@ class Part(models.Model):
|
||||
return self.default_location
|
||||
elif self.category:
|
||||
# Traverse up the category tree until we find a default location
|
||||
cat = self.category
|
||||
cats = self.category.get_ancestors(ascending=True, include_self=True)
|
||||
|
||||
while cat:
|
||||
if cat.default_location:
|
||||
for cat in cats:
|
||||
if cat.defaul_location:
|
||||
return cat.default_location
|
||||
else:
|
||||
cat = cat.parent
|
||||
|
||||
# Default case - no default category found
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user