[FIX] base, res_partner: fixed the name_search in order to propagate the right parameter to super() and to not use the '%' symbol if the operator is '='

bzr revid: qdp-launchpad@openerp.com-20120320154757-0o8q4pb2uch76su2
This commit is contained in:
Quentin (OpenERP) 2012-03-20 16:47:57 +01:00
parent 9bcfaf8d36
commit e37b9a5df3
1 changed files with 2 additions and 2 deletions

View File

@ -294,11 +294,11 @@ class res_partner(osv.osv):
args = []
if name and operator in ('=', 'ilike', '=ilike', 'like'):
# search on the name of the contacts and of its company
name = '%' + name + '%'
name2 = operator == '=' and name or '%' + name + '%'
cr.execute('''SELECT partner.id FROM res_partner partner
LEFT JOIN res_partner company ON partner.parent_id = company.id
WHERE partner.name || ' (' || COALESCE(company.name,'') || ')'
''' + operator + ''' %s ''', (name,))
''' + operator + ''' %s ''', (name2,))
ids = map(lambda x: x[0], cr.fetchall())
if args:
ids = self.search(cr, uid, [('id', 'in', ids)] + args, limit=limit, context=context)