Order locations by the MPTT left field when searching on quantities

This improves the likelihood that a full branch of locations will be calculated
in the same batch.

Closes #14182
This commit is contained in:
Cédric Krier committed 2025-08-22 10:11:57 +02:00
1 parent d72c4e2a95
commit 3c82eeca33
1 file changed
+1 -1
+1 -1
View File
@@ -460,7 +460,7 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView):
}.get(operator_, lambda v, l: False)
ids = []
for location in cls.search([]):
for location in cls.search([], order=[('left', 'ASC')]):
if operator_(getattr(location, name), operand):
ids.append(location.id)
return [('id', 'in', ids)]