تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
14182 أدوات العرض

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!!

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
نوفمبر 23
3104
7
أبريل 21
20469
1
أكتوبر 20
4849
2
نوفمبر 16
4202
1
مارس 15
13660