Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
21762 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
mar 18
4163
4
mar 16
6576
1
set 18
8701
0
mag 15
4915
3
giu 25
833