X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=openerp%2Fmodels.py;h=3f1bf70a54ee54ae558493d4e0846b9f43b124fc;hb=894a898e9e119ce0a101994c40cceae076a2bf13;hp=ad91afeb5d1f1539f2f792bf562ef11df4049a54;hpb=4bcb31f7060149831a26e030e64ee54b71e456b6;p=odoo%2Fodoo.git diff --git a/openerp/models.py b/openerp/models.py index ad91afe..3f1bf70 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -4774,14 +4774,15 @@ class BaseModel(object): By convention, new records are returned as existing. """ - ids = filter(None, self._ids) # ids to check in database + ids, new_ids = [], [] + for i in self._ids: + (ids if isinstance(i, (int, long)) else new_ids).append(i) if not ids: return self query = """SELECT id FROM "%s" WHERE id IN %%s""" % self._table - self._cr.execute(query, (ids,)) - ids = ([r[0] for r in self._cr.fetchall()] + # ids in database - [id for id in self._ids if not id]) # new ids - existing = self.browse(ids) + self._cr.execute(query, [tuple(ids)]) + ids = [r[0] for r in self._cr.fetchall()] + existing = self.browse(ids + new_ids) if len(existing) < len(self): # mark missing records in cache with a failed value exc = MissingError(_("Record does not exist or has been deleted."))