跳至內容
選單
此問題已被標幟
2 回覆
8422 瀏覽次數

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)

 

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
3月 24
1463
1
4月 16
3111
3
10月 15
11597
0
3月 15
3527
3
2月 25
35105