[FIX] orm: in modified() force target search ordering by 'id'

Some model can have really complex _order, which can induce unnecessary slow
queries; here as we don't need the right business order we force ordering by
'id' instead

OPW-2007478

closes odoo/odoo#36660

X-original-commit: a1fe8976156a7b6e14aa2d68650176a0e64ba73f
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
Raphael Collet
2019-09-10 19:05:12 +00:00
committed by fw-bot
parent 50e571acf7
commit 5032fc16b4
+1 -1
View File
@@ -5279,7 +5279,7 @@ Fields:
target0 = Model.browse(i for [i] in self.env.cr.fetchall())
else:
env = self.env(user=SUPERUSER_ID, context={'active_test': False})
target0 = env[model_name].search([(path, 'in', self.ids)])
target0 = env[model_name].search([(path, 'in', self.ids)], order='id')
target0 = target0.with_env(self.env)
# prepare recomputation for each field on linked records
for field in stored: