Skip to Content
Menú
This question has been flagged
2 Respostes
8401 Vistes

Hello odoo community,

I was wondering if its possible to make many2one field and when you type in something it would search by multiple criteria like (name, phone number, etc)?

Any example and help would be appreciated

Thank you

DM


Avatar
Descartar
Best Answer

Hello Darius,

try like below example.

@api.model
def name_search(self, name, args=None, operator='ilike', limit=100):
partners = self.search(['|', '|', ('name', operator, name), ('phone', operator, name), ('email', operator, name)]) # here you need to pass the args as per your requirement.
return partners.name_get()
Avatar
Descartar
Best Answer

By using name_search() Definition we can do it.

You can get an idea by seeing following sample code.

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

            recs = self.search(['|','|',('name', operator, name),('phone', operator, name),('mobile', operator, name)] + args, limit=limit)

 

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de març 24
1445
1
d’abr. 16
3095
3
d’oct. 15
11585
0
de març 15
3516
3
de febr. 25
35093