Hello everyone,
I am trying to make a searcher function for a function field that gets the rows (actually, the ids) of a table where the fields meets the same condition
Each field of the table is a fields.Selection() that has only the option ‘yes’ and ‘no’.
The class related to that table is call by a One2Many of another class, so, of course has a field that is a Many2One that is called ‘name’ (the fk pointing to the pk).
On sql, the sentence I need and works is the next:
select t.name
from mytable t
where (field1 = 'yes')::int
+ (field2 = 'yes')::int
+ (field3 = 'yes')::int >= 2
I try to make something like that, but without success.
query0 = (myTable.select(myTable.name,
where=(True if (
(1 if cTCall.field1 =='yes' else 0)+
(1 if cTCall.field2 =='yes' else 0)+
(1 if cTCall.field3 =='yes' else 0)+
)>2 else False)))
cursor.execute(*query0)
result0 = cursor.fetchall()
Ofcourse, this gives me an error.
So, any help or tip will be really appreciated. Thanks