コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
10922 ビュー

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

アバター
破棄
最善の回答

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

アバター
破棄
著作者

Excellent

thanks so much for your help :)

関連投稿 返信 ビュー 活動
2
1月 23
13744
0
4月 18
5565
0
3月 15
5296
2
1月 24
2567
2
6月 22
4499