Ir al contenido
Menú
Se marcó esta pregunta
4 Respuestas
12934 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar
Mejor respuesta
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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
jul 25
757
1
may 25
1507
1
may 25
1659
2
mar 25
1432
1
mar 25
1647