首页 > 代码库 > odoo xml 时间搜索条件

odoo xml 时间搜索条件


 今年

<filter string="This Year" name="year" domain="[(‘date‘,‘&lt;=‘, time.strftime(‘%%Y-12-31‘)),(‘date‘,‘&gt;=‘,time.strftime(‘%%Y-01-01‘))]"/>

今天

<filter icon="terp-go-today" string="Today" domain="[(‘date‘,‘&lt;=‘, datetime.datetime.combine(context_today(), datetime.time(23,59,59))), (‘date‘,‘&gt;=‘, datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]"/> 

上月
(‘date‘, ‘like‘, (context_today() - datetime.timedelta(month=1)).strftime(‘%%Y-%%m‘))  
(‘date‘, ‘like‘, (context_today() - relativedelta(month=1)).strftime(‘%%Y-%%m‘)) 

(‘picking_type_id‘,‘=‘,%(mtlcs_stock.picking_type_material_production)d ),(‘date‘,‘&lt;‘, time.strftime(‘%%Y-%%m-01‘)),(‘date‘,‘&gt;=‘,  (context_today() - relativedelta(months=1)).strftime(‘%%Y-%%m-01‘) ) 

(‘date‘, ‘&gt;=‘, ((context_today()+relativedelta(weeks=-2, days=1, weekday=0)).strftime(‘%%Y-%%m-%%d‘))),(‘date‘, ‘&lt;=‘, ((context_today()+relativedelta(weeks=-1, weekday=6)).strftime(‘%%Y-%%m-%%d‘)))

上周日
(‘date‘, ‘&lt;=‘, ((context_today()+relativedelta(weeks=-1, weekday=6)).strftime(‘%%Y-%%m-%%d‘))) 

 

上周一
(‘date‘, ‘&gt;=‘, ((context_today()+relativedelta(weeks=-2, days=1, weekday=0)).strftime(‘%%Y-%%m-%%d‘))) 

 

本周一
(‘date‘, ‘&gt;=‘, ((context_today()+relativedelta(weeks=-1, weekday=0)).strftime(‘%%Y-%%m-%%d‘))) 

 

实例:

<record id="inherit_iew_move_search" model="ir.ui.view">
            <field name="name">inherit.stock.move.search</field>
            <field name="model">stock.move</field>
            <field name=‘inherit_id‘ ref=‘stock.view_move_search‘/>
            <field name="arch" type="xml">
                <field name="name" position="after">
                    <field name="date" string="开始时间" filter_domain="[(‘date‘,‘>‘,self)]"/>
                    <field name="date" string="结束时间" filter_domain="[(‘date‘,‘<‘,self)]"/>
                </field>

                <filter name="ready" position="after">
                    <filter string="领料" name="slip"
                            domain="[(‘state‘,‘=‘,‘done‘),(‘picking_type_id‘,‘=‘,%(mtlcs_stock.picking_type_material_production)d )]"/>
                    
                    <filter string="今日领料" name="slip1"
                            domain="[(‘state‘,‘=‘,‘done‘),(‘picking_type_id‘,‘=‘,%(mtlcs_stock.picking_type_material_production)d ),(‘date‘, ‘<=‘, datetime.datetime.combine(context_today(), datetime.time(23,59,59))),(‘date‘,‘>=‘, datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]"/>
                    <filter string="本周领料" name="slip2"
                            domain="[(‘state‘,‘=‘,‘done‘),(‘picking_type_id‘,‘=‘,%(mtlcs_stock.picking_type_material_production)d ),(‘date‘, ‘>=‘, ((context_today()+relativedelta(weeks=-1, weekday=0)).strftime(‘%%Y-%%m-%%d‘))), ]"/>
                    <filter string="本月领料" name="slip3"
                            domain="[(‘state‘,‘=‘,‘done‘),(‘picking_type_id‘,‘=‘,%(mtlcs_stock.picking_type_material_production)d ),(‘date‘, ‘like‘, time.strftime(‘%%Y-%%m‘))]"/>
                    <filter string="上月领料" name="slip4"
                            domain="[(‘state‘,‘=‘,‘done‘),(‘picking_type_id‘,‘=‘,%(mtlcs_stock.picking_type_material_production)d ),(‘date‘, ‘<‘, time.strftime(‘%%Y-%%m-01‘)),(‘date‘,‘>=‘, (context_today() - relativedelta(months=1)).strftime(‘%%Y-%%m-01‘))]"/>
                    <separator/>

                    <filter string="退料" name="slip_return"
                            domain="[(‘state‘,‘=‘,‘done‘),(‘picking_type_id‘,‘=‘,%(mtlcs_stock.picking_type_material_production_return)d )]"/>
                    <filter string="收货" name="purchase"
                            domain="[(‘state‘,‘=‘,‘done‘),(‘picking_type_id‘,‘=‘,%(stock.picking_type_in)d )]"/>
                    <filter string="退货" name="purchase_return"
                            domain="[(‘state‘,‘=‘,‘done‘),(‘picking_type_id‘,‘=‘,%(mtlcs_stock.picking_type_purchase_input_return)d )]"/>
                </filter>
                <group string="Group By" position="inside">
                    <filter string="部门" name="groupby_department" icon="terp-gtk-jump-to-rtl" domain="[]"
                            context="{‘group_by‘:‘department_id‘}"/>
                </group>
            </field>
        </record>

odoo xml 时间搜索条件