我在同时使用两个或多个过滤器时遇到问题。
例如,如果我启用两个过滤器“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','<=', datetime.datetime.combine(context_today(), datetime.time(23,59,59))), ('route_time','>=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]"/>
<filter name="tomorrow" string="Tomorrow" domain="[('route_time','<=', datetime.datetime.combine(context_today()+datetime.timedelta(days=1), datetime.time(23,59,59))), ('route_time','>=', datetime.datetime.combine(context_today()+datetime.timedelta(days=1), datetime.time(0,0,0)))]"/>
</search>
</field>
</record>
答案 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','<=', datetime.datetime.combine(context_today(), datetime.time(23,59,59))), ('route_time','>=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]"/>
<separator />
<filter name="tomorrow" string="Tomorrow" domain="[('route_time','<=', datetime.datetime.combine(context_today()+datetime.timedelta(days=1), datetime.time(23,59,59))), ('route_time','>=', datetime.datetime.combine(context_today()+datetime.timedelta(days=1), datetime.time(0,0,0)))]"/>
</search>
</field>
</record>