Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
8455 มุมมอง

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)

 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มี.ค. 24
1488
1
เม.ย. 16
3126
3
ต.ค. 15
11622
0
มี.ค. 15
3539
3
ก.พ. 25
35144