mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-08 03:11:22 +00:00
Replace a recursive function
This commit is contained in:
1 parent
0d6a3d3b28
commit
a5189b8f3f
1 file changed
+3
-5
@@ -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
|
||||
|
||||
Reference in new issue
Block a user