[FIX] res.partner.address: name_search must treat limit=0|None as unlimited

lp bug: https://launchpad.net/bugs/971627 fixed

bzr revid: odo@openerp.com-20120409022248-bcwl80ok940w3elk
This commit is contained in:
Olivier Dony
2012-04-09 04:22:48 +02:00
parent 1b0a6ccdfc
commit fb05c2243a
+4 -2
View File
@@ -367,9 +367,11 @@ class res_partner_address(osv.osv):
# Searching on such a domain can be dramatically inefficient, due to the expansion made
# for field translations, and the handling of the disjunction by the DB engine itself.
# So instead, we search field by field until the search limit is reached.
while len(ids) < limit and fields:
while (not limit or len(ids) < limit) and fields:
f = fields.pop(0)
new_ids = self.search(cr, user, [(f, operator, name)] + args, limit=limit, context=context)
new_ids = self.search(cr, user, [(f, operator, name)] + args,
limit=(limit-len(ids) if limit else limit),
context=context)
# extend ids with the ones in new_ids that are not in ids yet (and keep order)
old_ids = set(ids)
ids.extend([id for id in new_ids if id not in old_ids])