Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
8735 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
bře 24
1754
1
dub 16
3361
3
říj 15
11871
0
bře 15
3717
3
úno 25
35702