Want to show a group of data by year, month, week in openerp 7
I have a date field in my object and from the data field I want to show the data in a group. I tried a data group using thise. But this has no effect.
Example:
<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"/>
<filter icon="terp-go-month" string="Month"
name="month"
domain="[('date_from','<=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('date_from','>=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
help="Current Month"/>
<filter icon="terp-go-week"
string="Week"
separator="1"
name="week"
domain="[('date_from','<=', (datetime.date.today() + relativedelta(weeks=0,day=7, weekday=-1)).strftime('%%Y-%%m-%%d')),('date_from','>=',(datetime.date.today() - relativedelta(weeks=1, weekday=0)).strftime('%%Y-%%m-%%d'))]"
help="Current Week"/>
Doesn't work for me :(
+3
user1576199
source
to share
1 answer
I changed a little.
<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"
context="{'group_by':'date_from'}"/>
<filter icon="terp-go-month"
string="Month"
name="month"
domain="[('date_from','<=',(context_today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('date_from','>=',(context_today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
help="Current Month"
context="{'group_by':'date_from'}"/>
<filter icon="terp-go-week"
string="Week"
separator="1"
name="week"
domain="[('date_from','<=', (context_today() + relativedelta(weeks=0,day=7, weekday=-1)).strftime('%%Y-%%m-%%d')),('date_from','>=',(context_today() - relativedelta(weeks=1, weekday=0)).strftime('%%Y-%%m-%%d'))]"
help="Current Week"
context="{'group_by':'date_from'}"/>
Here I added context="{'group_by':'date_from'}"
in each filter and instead datetime.date.today()
I replaced it with context_today()
.
It will now work correctly.
+1
Keyur
source
to share