Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3375 Widoki

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!

Awatar
Odrzuć
Najlepsza odpowiedź

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'))]"/>

Awatar
Odrzuć
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'))]

Powiązane posty Odpowiedzi Widoki Czynność
3
lis 24
1160
0
paź 23
1440
3
sie 23
2895
3
wrz 20
5964
0
sty 18
5267