Filters for Datetime field
Today Filter
<filter icon="terp-go-month" string="Today " separator="1" domain="[('date','<=', (datetime.date.today()).strftime('%Y-%m-%d')),('date','>=',(datetime.date.today()).strftime('%Y-%m-%d'))]" help="Created today"/>
OR
<filter icon="terp-go-today" string="Today" domain="[('date','<=', datetime.datetime.combine(context_today(), datetime.time(23,59,59))), ('date','>=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]" help="Orders processed Today or planned for Today"/>
This Year
<filter string="This Year" name="year" domain="[('date','<=', time.strftime('%%Y-12-31')),('date','>=',time.strftime('%%Y-01-01'))]"/>
Last Week
<filter string="Last week" domain="[('date_order', '>=', ((context_today()+relativedelta(weeks=-2, days=1, weekday=0)).strftime('%Y-%m-%d'))),('date_order', '<=', ((context_today()+relativedelta(weeks=-1,weekday=6)).strftime('%Y-%m-%d')))]"/>
This Month
<filter icon="terp-go-month" string="Month" name="month" domain="[('date_order','<=',(datetime.date.today()+relativedelta(day=31)).strftime('%Y-%m-%d')),('date_order','>=',(datetime.date.today()-relativedelta(day=1)).strftime('%Y-%m-%d'))]" help="Current Month"/>
Current week
<filter icon="terp-go-week"
string="Current Week"
separator="1"
name="week"
domain="[('date_order','<=', (context_today() + relativedelta(weeks=0,day=7, weekday=-1)).strftime('%Y-%m-%d')),('date_order','>=',(context_today() - relativedelta(weeks=1, weekday=0)).strftime('%Y-%m-%d'))]"
help="Current Week"
context="{'group_by':'date_order'}"/>
Previous Month
<filter string="Prev Month" name="prev_month" domain="[('date_order','>=',(context_today()-relativedelta(months=1)).strftime('%Y-%m-01')),('date_order','<',time.strftime('%Y-%m-01'))]"/>
Expiry checking
<filter string="Immediate Expiry" name="od_imm" domain="[('expiry_date','>=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d'))),('expiry_date','<=', ((context_today()+datetime.timedelta(days=45)).strftime('%Y-%m-%d')))]"/>
Yesterday
<filter string="Yesterday" domain="[('date_order','>=', ((context_today()-datetime.timedelta(days=1)).strftime('%Y-%m-%d 00:00:00'))), ('date_order','<=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d 00:00:00')))]"/>
Tomorrow
<filter string="Tomorrow" domain="[('date_order','>=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d 23:59:59'))), ('date_order','<=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d 23:59:59')))]"/>
Filters for Selection Field
Eg:<filter string="Quotations" name="draft" domain="[('state','in',('draft','sent'))]" help="Sales Order that haven't yet been confirmed"/>
Eg:<filter string="To Invoice" domain="[('state','=','manual')]" help="Sales Order ready to be invoiced"/>
Filters for Boolean Field
Eg:<filter icon="terp-gtk-jump-to-ltr" string="To Review" domain="[('to_check','=',True)]" help="Journal Entries to Review"/>
Filters for Many2one Field
<filter domain="[('user_id','=',uid)]" help="My Invoices" string="My Invoices"/>
for many2one field we are usually adding group by instead of filters.
you can add filters for many2one field by hard coding ids
Eg:-<filter domain="[('partner_id','in',(1,2,9,8,22)]" help="Selected" string="Special Partners"/>
Eg:-<filter domain="[('partner_id','=',1]" help="Selected" string="My Order"/>
Filters for Date Field
This week
<filter string="This Week" name="This Week" separator="1"
domain="[('date_from','>=', ((context_today()).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')))]"
help="This Week"/>
Last Week
<filter string="Last Week" name="Last Week" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=-7)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()).strftime('%Y-%m-%d')))]"
help="This Week"/>
yesterday
<filter string="Yesterday" name="Yesterday" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=-1)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=-1)).strftime('%Y-%m-%d')))]"
help="Yesterday"/>
Today
<filter string="Today" name="Today" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d')))]"
help="Today"/>
Tomorrow
<filter string="Tomorrow" name="Tomorrow" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d')))]"
help="Tomorrow"/>
Expiry
<filter string="Immediate Expiry" name="Immediate Expiry" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=45)).strftime('%Y-%m-%d')))]"
help="Immediate Expiry"/>
Last Month
<filter icon="terp-go-month" string="Last Month"
domain="[('date_from','<=', (context_today()-relativedelta(day=31, months=1)).strftime('%Y-%m-%d')),
('date_from','>=',(context_today()-relativedelta(day=1,months=1)).strftime('%Y-%m-%d'))]"
help="last month"/>
Current Month
<filter string="Current Month" name="current_month" domain="[('date_from','<',(context_today()+relativedelta(months=1)).strftime('%Y-%m-01')), ('date_from','>=',time.strftime('%Y-%m-01'))]"/>
Last Year
<filter icon="terp-go-month" string="Last Year"
domain="[('date', '>=' ,(context_today()-relativedelta(years=1)).strftime('%Y-01-01')),('date','<=',time.strftime('%Y-01-01'))]" help="last year"/>
This Year
<filter icon="terp-go-year" string="Year"
domain="[('date_from','<=', time.strftime('%Y-%m-%d')),('date_from','>=',time.strftime('%Y-01-01'))]"
help="Current Year"/>
Today Filter
<filter icon="terp-go-month" string="Today " separator="1" domain="[('date','<=', (datetime.date.today()).strftime('%Y-%m-%d')),('date','>=',(datetime.date.today()).strftime('%Y-%m-%d'))]" help="Created today"/>
OR
<filter icon="terp-go-today" string="Today" domain="[('date','<=', datetime.datetime.combine(context_today(), datetime.time(23,59,59))), ('date','>=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]" help="Orders processed Today or planned for Today"/>
This Year
<filter string="This Year" name="year" domain="[('date','<=', time.strftime('%%Y-12-31')),('date','>=',time.strftime('%%Y-01-01'))]"/>
Last Week
<filter string="Last week" domain="[('date_order', '>=', ((context_today()+relativedelta(weeks=-2, days=1, weekday=0)).strftime('%Y-%m-%d'))),('date_order', '<=', ((context_today()+relativedelta(weeks=-1,weekday=6)).strftime('%Y-%m-%d')))]"/>
This Month
<filter icon="terp-go-month" string="Month" name="month" domain="[('date_order','<=',(datetime.date.today()+relativedelta(day=31)).strftime('%Y-%m-%d')),('date_order','>=',(datetime.date.today()-relativedelta(day=1)).strftime('%Y-%m-%d'))]" help="Current Month"/>
Current week
<filter icon="terp-go-week"
string="Current Week"
separator="1"
name="week"
domain="[('date_order','<=', (context_today() + relativedelta(weeks=0,day=7, weekday=-1)).strftime('%Y-%m-%d')),('date_order','>=',(context_today() - relativedelta(weeks=1, weekday=0)).strftime('%Y-%m-%d'))]"
help="Current Week"
context="{'group_by':'date_order'}"/>
Previous Month
<filter string="Prev Month" name="prev_month" domain="[('date_order','>=',(context_today()-relativedelta(months=1)).strftime('%Y-%m-01')),('date_order','<',time.strftime('%Y-%m-01'))]"/>
Expiry checking
<filter string="Immediate Expiry" name="od_imm" domain="[('expiry_date','>=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d'))),('expiry_date','<=', ((context_today()+datetime.timedelta(days=45)).strftime('%Y-%m-%d')))]"/>
Yesterday
<filter string="Yesterday" domain="[('date_order','>=', ((context_today()-datetime.timedelta(days=1)).strftime('%Y-%m-%d 00:00:00'))), ('date_order','<=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d 00:00:00')))]"/>
Tomorrow
<filter string="Tomorrow" domain="[('date_order','>=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d 23:59:59'))), ('date_order','<=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d 23:59:59')))]"/>
Filters for Selection Field
Eg:<filter string="Quotations" name="draft" domain="[('state','in',('draft','sent'))]" help="Sales Order that haven't yet been confirmed"/>
Eg:<filter string="To Invoice" domain="[('state','=','manual')]" help="Sales Order ready to be invoiced"/>
Filters for Boolean Field
Eg:<filter icon="terp-gtk-jump-to-ltr" string="To Review" domain="[('to_check','=',True)]" help="Journal Entries to Review"/>
Filters for Many2one Field
<filter domain="[('user_id','=',uid)]" help="My Invoices" string="My Invoices"/>
for many2one field we are usually adding group by instead of filters.
you can add filters for many2one field by hard coding ids
Eg:-<filter domain="[('partner_id','in',(1,2,9,8,22)]" help="Selected" string="Special Partners"/>
Eg:-<filter domain="[('partner_id','=',1]" help="Selected" string="My Order"/>
Filters for Date Field
This week
<filter string="This Week" name="This Week" separator="1"
domain="[('date_from','>=', ((context_today()).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')))]"
help="This Week"/>
Last Week
<filter string="Last Week" name="Last Week" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=-7)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()).strftime('%Y-%m-%d')))]"
help="This Week"/>
yesterday
<filter string="Yesterday" name="Yesterday" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=-1)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=-1)).strftime('%Y-%m-%d')))]"
help="Yesterday"/>
Today
<filter string="Today" name="Today" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d')))]"
help="Today"/>
Tomorrow
<filter string="Tomorrow" name="Tomorrow" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d')))]"
help="Tomorrow"/>
Expiry
<filter string="Immediate Expiry" name="Immediate Expiry" separator="1"
domain="[('date_from','>=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d'))), ('date_from','<=', ((context_today()+datetime.timedelta(days=45)).strftime('%Y-%m-%d')))]"
help="Immediate Expiry"/>
Last Month
<filter icon="terp-go-month" string="Last Month"
domain="[('date_from','<=', (context_today()-relativedelta(day=31, months=1)).strftime('%Y-%m-%d')),
('date_from','>=',(context_today()-relativedelta(day=1,months=1)).strftime('%Y-%m-%d'))]"
help="last month"/>
Current Month
<filter string="Current Month" name="current_month" domain="[('date_from','<',(context_today()+relativedelta(months=1)).strftime('%Y-%m-01')), ('date_from','>=',time.strftime('%Y-%m-01'))]"/>
Last Year
<filter icon="terp-go-month" string="Last Year"
domain="[('date', '>=' ,(context_today()-relativedelta(years=1)).strftime('%Y-01-01')),('date','<=',time.strftime('%Y-01-01'))]" help="last year"/>
This Year
<filter icon="terp-go-year" string="Year"
domain="[('date_from','<=', time.strftime('%Y-%m-%d')),('date_from','>=',time.strftime('%Y-01-01'))]"
help="Current Year"/>
No comments:
Post a Comment