Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
4 Replies
12995 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai
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
Buang
Post Terkait Replies Tampilan Aktivitas
0
Jul 25
856
1
Mei 25
1587
ADD PROPERTIES Diselesaikan
1
Mei 25
2361
2
Mar 25
1501
1
Mar 25
2336