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

When do search filters get "AND"ed and when do they get "OR"ed?

By
Alex Malone
on 4/25/13, 10:19 AM 648 views

Hi folks,

I am experiencing some weird behaviour with some of my search filters. The code:

<search string="Search Timelogs">
                    <!-- Filters -->
                    <filter name="filter_today_timelogs" string="Today" domain="[('log_date','<=',time.strftime('%%Y-%%m-%%d 23:59:59')),('log_date','>=',time.strftime('%%Y-%%m-%%d 00:00:00'))]" />
                    <filter name="filter_my_timelogs" string="My Timelogs"  domain="[('log_user_id','=',uid)]" />
                    <filter name="filter_running_timelogs" string="Running Timelogs" domain="[('state','=','running')]" />
                    <!-- Fields -->
                    <field name="log_date" filter_domain="[('log_date','=',self)]" />
                    <field name="type_id" filter_domain="[('type_id','ilike',self)]" />
                    <field name="company_id" filter_domain="[('company_id','ilike',self)]" />
                    <field name="log_user_id" filter_domain="[('log_user_id','ilike',self)]" />
                    <field name="notes" filter_domain="[('notes','ilike',self)]" />
                    <field name="state" filter_domain="[('state','ilike',self)]" />
                    <!-- Group By -->
                    <group expand="0" string="Group By...">
                        <filter string="Type" icon="terp-personal" domain="[]" context="{'group_by':'type_id'}"/>
                    </group>
                </search>

The problem I am currently having is that the three filter buttons are not working as I would expect them to. Each filter works when used individually, so clicking on "Today" only shows today's timelogs for example.

However, when I click multiple filters they do not behave as expected.

The first filter, "Today", always gets ANDed. The second filter, "My Timelogs", always gets ANDed The third filter, "Running Timelogs", always gets ORed!

Examples:

"Today" + "My Timelogs" = only shows my timelogs from today (Today AND My) "Today" + "Running" = shows any running timelogs or any of todays (Today OR Running) "Today" + "My Timelogs" + "Running" = shows my timelogs from today or any running ones ( (Today AND My) OR Running )

This is not the behaviour I would expect from the system and it seems like a bug, it is certainly different to how version 6 behaved and so this is going to cause problems with our customers.

Can anyone spot anything "weird" with my filter definitions that might be causing the problem? Or has anyone else had this problem themselves?

Many thanks in advance,

-Alex

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

0 follower(s)

Stats

Asked: 4/25/13, 10:19 AM
Seen: 648 times
Last updated: 3/16/15, 8:10 AM