Skip to Content
Menu
This question has been flagged
4 Replies
11588 Views

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Best Answer
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
Discard
Related Posts Replies Views Activity
1
Jun 24
3667
0
Feb 24
534
1
Feb 23
2288
8
Apr 22
82440
1
Oct 21
1522