Skip to Content
Menu
This question has been flagged
1 Reply
2290 Views

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
Discard
Best Answer

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
Discard
Author

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 Replies Views Activity
3
Nov 24
86
0
Oct 23
633
3
Aug 23
1716
3
Sep 20
4813
0
Jan 18
4170