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
|
return self.default_location
|
||||||
elif self.category:
|
elif self.category:
|
||||||
# Traverse up the category tree until we find a default location
|
# 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:
|
for cat in cats:
|
||||||
if cat.default_location:
|
if cat.defaul_location:
|
||||||
return cat.default_location
|
return cat.default_location
|
||||||
else:
|
|
||||||
cat = cat.parent
|
|
||||||
|
|
||||||
# Default case - no default category found
|
# Default case - no default category found
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user