Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
8362 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
2
mars 24
1408
1
avr. 16
3070
3
oct. 15
11560
0
mars 15
3503
3
févr. 25
35037