From 3c82eeca33eb29c4b2ded042276153f0c0f0d2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 22 Aug 2025 10:11:57 +0200 Subject: [PATCH] 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 --- modules/stock/location.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/stock/location.py b/modules/stock/location.py index 158e39a11e..95ed005625 100644 --- a/modules/stock/location.py +++ b/modules/stock/location.py @@ -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)]