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

Hi,I want to change date format for some date field.Not for all date field.I know I can change for all using Settings --> Translations --> Languages.But I want to change some particular field only.I try to use this but not work. 

My code example:

 




アバター
破棄
最善の回答

Hello, you can try below process :

Translations --> Language --> Edit

Replace time format : %H:%M:%S to %I:%M:%S %p

import following:

from odoo.tools import float_is_zero, float_compare, DEFAULT_SERVER_DATETIME_FORMAT

define in your function in place of time format DEFAULT_SERVER_DATETIME_FORMAT i hope it helps you.


For Reports and XML(QWeb) you can do it this way:

<span t-esc="datetime.datetime.strptime(object.date, '%Y-%m-%d %H:%M:%S').strftime('%d/%m/%Y %I:%M:%S %p')"/>

Hope it helps

アバター
破棄
関連投稿 返信 ビュー 活動
3
1月 25
5351
1
8月 24
3468
0
9月 21
3519
0
3月 15
5372
3
5月 25
7059