summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/stock/models/product.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py
index 3d19c83be64..09408f6c694 100644
--- a/addons/stock/models/product.py
+++ b/addons/stock/models/product.py
@@ -262,7 +262,9 @@ class Product(models.Model):
# TODO: Still optimization possible when searching virtual quantities
ids = []
- for product in self.search([]):
+ # Order the search on `id` to prevent the default order on the product name which slows
+ # down the search because of the join on the translation table to get the translated names.
+ for product in self.search([], order='id'):
if OPERATORS[operator](product[field], value):
ids.append(product.id)
return [('id', 'in', ids)]