[FIX] base_contact: search in "Contact's Jobs" now also search in firstname and lastname of contacts

bzr revid: olt@tinyerp.com-20100201075852-eomf4z7an0rno10r
This commit is contained in:
olt@tinyerp.com 2010-02-01 08:58:52 +01:00
parent e5be0142c4
commit b1643c7af6
1 changed files with 18 additions and 6 deletions

View File

@ -114,17 +114,29 @@ class res_partner_job(osv.osv):
res = []
for r in self.browse(cr, uid, ids):
funct = r.function_id and (", " + r.function_id.name) or ""
res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] + funct ))
res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] + funct))
return res
def search(self, cr, user, args, offset=0, limit=None, order=None,
context=None, count=False):
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
job_ids = []
for arg in args:
if arg[0]=='address_id':
if arg[0] == 'address_id':
self._order = 'sequence_partner'
if arg[0]=='contact_id':
elif arg[0] == 'contact_id':
self._order = 'sequence_contact'
return super(res_partner_job,self).search(cr, user, args, offset, limit, order, context, count)
elif arg[0] == 'name':
contact_obj = self.pool.get('res.partner.contact')
search_arg = ['|', ('first_name', 'ilike', arg[2]), ('name', 'ilike', arg[2])]
contact_ids = contact_obj.search(cr, user, search_arg, offset=offset, limit=limit, order=order, context=context, count=count)
contacts = contact_obj.browse(cr, user, contact_ids, context=context)
for contact in contacts:
job_ids.extend([item.id for item in contact.job_ids])
res = super(res_partner_job,self).search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
if job_ids:
res = list(set(res + job_ids))
return res
_name = 'res.partner.job'
_description ='Contact Partner Function'