Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
4 Vastaukset
12873 Näkymät

hello,

i wanted to know how to filter by reord for the current week from monday that means if today is monday i want all the record from today to next monday if we are sunday i want all the record from last monday to next monday no matter which day we are i want from this week monday to the next

thanks a lot

Avatar
Hylkää
Paras vastaus

Hello, Current Week Filter could be achieved with the following code :

<filter string="Current Week" name="current_week"

domain="[('helpdesk_ticket_create_date', '&lt;=', ((context_today()+relativedelta(weeks=0, weekday=-1)).strftime('%Y-%m-%d'))),

('helpdesk_ticket_create_date', '&gt;=', ((context_today()-relativedelta(weeks=1, weekday=0)).strftime('%Y-%m-%d')))]"/>

So it doesn't matter which day is today, this code filters on weekly basis only.


Regards,

Darshan!


Avatar
Hylkää
Paras vastaus

Hello brami,


You can create a filter like this,

<filter string="Current Week" name="Current Week" domain="[('date','&lt;',(context_today()+relativedelta(days=7)).strftime('%Y-%m-%d 23:59:59')), ('date','&gt;=',context_today().strftime('%Y-%m-%d 00:00:00'))]"/>


This will give you the filter you require for the current week. For eg, if today is Monday then records till next Monday.


Hope this helps,

Thank You.

Avatar
Hylkää
Paras vastaus

Burhan Vakharia's solution doesn't seem to work.

It returns records from [today] to [today + 7 days].

That's not what avasen was looking for. If today is saturday, he wants to see record from last monday to next monday, not records from saturday (today) to next saturday.

Thank you for the help, though!

Avatar
Hylkää
Paras vastaus
Hello,
The perfect solution was in the base(addons/im_livechat/views).

<filter string="This Week" name="creation_date_filter" domain="[
('create_date', '>=', (datetime.datetime.combine(context_today() + relativedelta(weeks=-1,days=1,weekday=0), datetime.time(0,0,0)).to_utc()).strftime('%Y-%m-%d %H:%M:%S')),
('create_date', '/>


Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
heinäk. 25
167
1
toukok. 25
1164
1
toukok. 25
1181
2
maalisk. 25
1134
1
maalisk. 25
1172