From fb05c2243a448e75fa77416d50b44935a862520e Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 9 Apr 2012 04:22:48 +0200 Subject: [PATCH] [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 --- openerp/addons/base/res/res_partner.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/res/res_partner.py b/openerp/addons/base/res/res_partner.py index 9c98521e86c..71626d201b3 100644 --- a/openerp/addons/base/res/res_partner.py +++ b/openerp/addons/base/res/res_partner.py @@ -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])