[IMP] core: make exists determinist

When testing odoo, errors can occur an undeterministic way, wich can
lead to strange and unreproductible behaviour.  This also means that the
performance can change from one execution to another, making it quite
difficult to track performance variation on a global scope.

This commit makes the result of `exists()` deterministic in terms of
order.  The side effect is to keep record ids in the same order as the
original recordset, which may be useful.

closes odoo/odoo#47282

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
Xavier-Do
2020-03-12 09:37:04 +00:00
committed by Raphael Collet
co-authored by Raphael Collet
parent dad3556e97
commit 03708af20e
+2 -2
View File
@@ -4611,8 +4611,8 @@ Record ids: %(records)s
return self
query = """SELECT id FROM "%s" WHERE id IN %%s""" % self._table
self._cr.execute(query, [tuple(ids)])
ids = [r[0] for r in self._cr.fetchall()]
return self.browse(ids + new_ids)
valid_ids = set([r[0] for r in self._cr.fetchall()] + new_ids)
return self.browse(i for i in self._ids if i in valid_ids)
def _check_recursion(self, parent=None):
"""