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

Hi,

How to do compare ignoring case in search filter? For instance in the below code

ids = self.pool.get('product.product').search(cr, uid, [('name', '=', 'Service'))], context=context)

i am comparing the name of the product with string 'Service'. i want to compare ignoring its case something similar to below

ids = self.pool.get('product.product').search(cr, uid, [('name'.upper(), '=', 'Service'.upper()))], context=context)

I can use 'service'.upper but not 'name'.upper. So how do i compare ignoring its case. Thanks for your time.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You can use ilike operator instead of = in search domain. It ignores case.

Try this:

ids = self.pool.get('product.product').search(cr, uid, [('name', 'ilike', 'Service'))], context=context)

Hope this is what you are looking for.

อวตาร
ละทิ้ง
ผู้เขียน

oh! Thanks sudhir, i actually forgot that option!!

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ย. 23
3187
7
เม.ย. 21
20566
filter with related model field แก้ไขแล้ว
1
ต.ค. 20
4939
change search filter แก้ไขแล้ว
2
พ.ย. 16
4291
1
มี.ค. 15
13731