Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3341 Vistas

I want to create a relative filter with studio in which it shows me, for example, THIS YEAR'S invoices.

I have managed to create relative filters, for example, to TODAY's date minus x days:

["&",["create_date",">=",datetime.datetime.now()-datetime.timedelta(days=365)],["create_date","<=",datetime.datetime.now() ]]

NOTE: I know that filter comes by default. But I need to create a new one that shows me the invoices for this year. I have a pivot view on my dashboard and I want it to automatically change every year. If I use that filter, the dashboard view will not change to 2023.

But I don't know how to create a filter for THIS YEAR, can you help me?

Thank you very much community!

Avatar
Descartar
Mejor respuesta

Hi, You can use the below to add filters:

For Today:

<filter string="Today" name="today" domain="[('craete_date', '&gt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),('craete_date', '&lt;=',datetime.datetime.now().strftime('%Y-%m-%d 23:59:59'))]"/>

for This Year filter:

<filter string="This Year" name="year" domain="[('craete_date','&lt;=', time.strftime('%%Y-12-31')),('craete_date','&gt;=',time.strftime('%%Y-01-01'))]"/>

Avatar
Descartar
Autor

Thank you very much!!! I have been blocked for days and trying to get the magic formula and you have helped me a lot. I sincerely thank you very much for your answer, you have helped me a lot.

Finally what I was looking for was this:

[('invoice_date','&lt;=', time.strftime('%%Y-12-31')),('invoice_date','&gt;=',time.strftime('%%Y-01-01'))]

Publicaciones relacionadas Respuestas Vistas Actividad
3
nov 24
1131
0
oct 23
1401
3
ago 23
2840
3
sept 20
5916
0
ene 18
5256