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

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

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
Zrušit
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'))]

Related Posts Odpovědi Zobrazení Aktivita
3
lis 24
1149
0
říj 23
1424
3
srp 23
2876
3
zář 20
5955
0
led 18
5260