İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
10796 Görünümler

how convert a datetime field and compare with current date?

hi

I want to write a search view and define a filter in it, that compare "created_date" with "current date" and show all of requests that created today.

problem1: how write filter that get only date from "create_date" (because this field is datetime format)

problem2: how compare with current date?

<record id="support_services_view_search" model="ir.ui.view">

....

<filter name="today" string="Today" domain="[('??(how get date)???create_date','=',???]"/>


thanks

Avatar
Vazgeç
En İyi Yanıt

Hi,

You can use the below:


<filter string="Today" domain="[('datetime_field', '&gt;=', datetime.datetime.combine(context_today(), datetime.time(0,0,0))),
('datetimefield', '&lt;=', datetime.datetime.combine(context_today(), datetime.time(23,59,59)))]" />

Avatar
Vazgeç
Üretici

Excellent

thanks so much for your help :)

İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Oca 23
13594
0
Nis 18
5455
0
Mar 15
5130
2
Oca 24
2382
2
Haz 22
4345