odoo同时使用两个过滤器

时间:2017-02-23 16:08:01

标签: xml openerp odoo-8

我在同时使用两个或多个过滤器时遇到问题。

例如,如果我启用两个过滤器“Today”和“Tomorrow”,则SQL查询将其识别为“Today or Tomorrow”句子。

有没有办法让它成为Today AND Tomorrow句子,所以SQL查询会考虑两者?我不想制作第三个过滤器Today and Tomorrow

我的XML代码在这里:

<record id="view_klient_tellimus" model="ir.ui.view">
    <field name="name">picking.klient.tellimus.filter</field>
    <field name="model">stock.picking</field>
    <field name="arch" type="xml">
        <search string="Search Picking">
            <filter name="today" string="Today" domain="[('route_time','&lt;=', datetime.datetime.combine(context_today(), datetime.time(23,59,59))), ('route_time','&gt;=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]"/>
            <filter name="tomorrow" string="Tomorrow" domain="[('route_time','&lt;=', datetime.datetime.combine(context_today()+datetime.timedelta(days=1), datetime.time(23,59,59))), ('route_time','&gt;=', datetime.datetime.combine(context_today()+datetime.timedelta(days=1), datetime.time(0,0,0)))]"/>
        </search>
    </field>
</record>

1 个答案:

答案 0 :(得分:1)

您好,您需要将separator用于AND过滤器。

所以试试这个:

<record id="view_klient_tellimus" model="ir.ui.view">
    <field name="name">picking.klient.tellimus.filter</field>
    <field name="model">stock.picking</field>
    <field name="arch" type="xml">
        <search string="Search Picking">
            <filter name="today" string="Today" domain="[('route_time','&lt;=', datetime.datetime.combine(context_today(), datetime.time(23,59,59))), ('route_time','&gt;=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]"/>
            <separator />
            <filter name="tomorrow" string="Tomorrow" domain="[('route_time','&lt;=', datetime.datetime.combine(context_today()+datetime.timedelta(days=1), datetime.time(23,59,59))), ('route_time','&gt;=', datetime.datetime.combine(context_today()+datetime.timedelta(days=1), datetime.time(0,0,0)))]"/>
        </search>
    </field>
</record>