تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
21733 أدوات العرض

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.

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مارس 18
4150
4
مارس 16
6574
1
سبتمبر 18
8687
0
مايو 15
4904
3
يونيو 25
821