Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
21765 Tampilan

I want to display and make selectable a particular datetime field in 12 hour format in  Odoo 8. Generically, it is done by Settings->Translation->Time Format , but i want to do it with a single field on form view.

Any help will be highly appreciated.

Avatar
Buang
Jawaban Terbai

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.

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
0
Mar 18
4163
4
Mar 16
6576
1
Sep 18
8706
0
Mei 15
4916
3
Jun 25
835