This question has been flagged
3 Replies
2701 Views

```

@api.model 

def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): 

if operator in ('ilike', 'like', '=', '=like', '=ilike'): 

args = expression.AND([ args or [], ['|', ('visitor.id_proof_no', operator, name), ('visitor', operator, name)] ]) 

return super(VisitDetails, self)._name_search(name, args=args, operator=operator, limit=limit, name_get_uid=name_get_uid)

```

its working fine on Name but not search on id_proof_no ...... 

name is like XYZ and id_proof_no is = 33333333333333

id_proof_no and name both are Char fields

Avatar
Discard

in which class you have added id_proof_no, if it is in same class visitDetails than no need to add visitor.id_proof_no just add id_proof_no in domain. Second thing if id_proof_no is integer field, so make sure you convert name into integer and than add into domain so it gives you proper result.

Author

@Bhaviraj Brahmkshatriya

id_proof_no is char field and it is not in same class its on other class

Author Best Answer

@api.multi 

def name_get(self): 

 result = [] 

 for prod in self:

 result.append((prod.id, "%s - %s" % ( prod.name, prod.id_proof_no or '')))

 return result
    

@api.model

 def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):

 args = args or [] if operator == 'ilike' and not (name or '').strip(): 

 domain = [] else: domain = ['|', ('name', 'ilike', name), ('id_proof_no', 'ilike', name)] 

 sat_code_ids = self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid) 

 return self.browse(sat_code_ids).name_get()

Avatar
Discard