Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to create an advanced user defined filter

By
Carlos Almeida
on 1/10/16, 9:21 PM 497 views

I need to create a user defined filter like this:

if (field1 = 10 and field2 = 12) or (field3 = 13 and field4 = 13) or (field5 = 15 and field6 = 16)


In Settings->User Interface->User-defined Filters, I've created a filter like this:

['|', '|', ['&', ['field1', '=', 10], ['field2', '=', 12]], ['&', ['field2', '=', 13], ['field4', '=', 14]], ['&', ['field5', '=', 15], ['field6', '=', 16]]]


But it's giving error on client browser:

ValueError: Invalid leaf ['&', ['field1', '=', 10], ['field2', '=', 12]]


What is the correct way to do it?

1

Temur

--Temur--
2894
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 1/11/16, 4:44 AM

You're using too much parentheses for polish notation...

you should use something like:

['|', '|', '&', ('field1', '=', 10), ('field2', '=', 12),'&', ('field2', '=', 13), ('field4', '=', 14), '&', ('field5', '=', 15), ('field6', '=', 16)]
0

Jignesh Mehta

--Jignesh Mehta--
2081
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 1/11/16, 2:54 AM

Hello Carlos,


Try this :-

['|', '|', [('field1', '=', 10), ('field2', '=', 12)], [('field3', '=', 13), ('field4', '=', 13)], [('field5', '=', 15), ('field6', '=', 16)]]


Hope it will help you


Thanks,


it doesn't work this way, Temur gave correct answer Thanks any way

Carlos Almeida
on 1/11/16, 10:18 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/10/16, 9:21 PM
Seen: 497 times
Last updated: 1/11/16, 10:17 AM