Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
3363 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
3
Nov 24
1152
0
Okt 23
1424
3
Agu 23
2879
3
Sep 20
5957
0
Jan 18
5260