Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
10949 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhấ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)))]" />

Ảnh đại diện
Huỷ bỏ
Tác giả

Excellent

thanks so much for your help :)

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 1 23
13776
0
thg 4 18
5581
0
thg 3 15
5320
2
thg 1 24
2590
2
thg 6 22
4522