Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
12996 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď
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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
čvc 25
859
1
kvě 25
1592
ADD PROPERTIES Vyřešeno
1
kvě 25
2408
2
bře 25
1502
1
bře 25
2390