Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
21749 Vizualizări

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
mar. 18
4153
4
mar. 16
6575
1
sept. 18
8688
0
mai 15
4905
3
iun. 25
826