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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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
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()
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)
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Mar 24
|
303 | ||
|
1
Apr 16
|
2153 | ||
|
3
Oct 15
|
10163 | ||
|
0
Mar 15
|
2567 | ||
|
1
Sep 24
|
181 |