Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
21777 Ansichten

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
Verwerfen
Beste Antwort

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
Verwerfen
Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
März 18
4175
4
März 16
6580
1
Sept. 18
8721
0
Mai 15
4932
3
Juni 25
864