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

i want to display only the year from request_date_from in a q-web report 

i tried this code 

 <span t-esc="datetime.datetime.strptime(o.request_date_from, '%Y-%m-%d').strftime('%Y')"/>

but i get this error 


Error to render compiling AST TypeError: strptime() argument 1 must be str, not datetime.date Template: mymodule.leave 
Path: /t/t/t/t/div/p/span
Node: <span t-esc="datetime.datetime.strptime(o.request_date_from, '%Y-%m-%d').strftime('%Y')"/>)
アバター
破棄
著作者

thank you  @Ravi Gadhia 

最善の回答

<span t-field="o.request_date_from" t-options='{"format": "yyyy"}'/>

you can use any babel format http://babel.pocoo.org/en/latest/dates.html#date-fields

アバター
破棄
関連投稿 返信 ビュー 活動
0
7月 21
2138
2
3月 24
2477
1
2月 23
2943
1
10月 21
7788
3
6月 25
897