Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
51591 มุมมอง

Hi,

On a form view, I try to change the format used to display a field Date.
I don't want to change the format of all fields Date, just for one field.

In QWeb, I can use this syntax: 

<span t-field="blog_post.create_date" t-field-options='{"format": "MMMM yyyy"}'/>

Is it possible to do the same thing of form view, without editing date format on lang parameters ?


อวตาร
ละทิ้ง

odoo dosen't have that kind of feature till odoo v8, If you know web customization than develop your own widget which accept the format parameter and display date value based on format passed from the form view.

ผู้เขียน

Thank you, I will try to develop my own Date widget with an option for format.

คำตอบที่ดีที่สุด

You can do that with a widget:

<field name="date_order" widget="date"/>
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Dear Isabelle Richard,

First you need to enable the Technical Features under your user account, then go to

Settings ->Translations -> Languages.

Edit your current language and change the date format

Thanks & Regards

Ankit H Gandhi.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Use this module:

https://github.com/OCA/web/tree/8.0/web_widget_datepicker_options

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

It seems like o.date_order it's not a datetime object but a string. Using the time module is the way to go:

<span t-esc="time.strftime('%A, %d %B %Y',time.strptime(o.date_order,'%Y-%m-%d %H:%M:%S'))"/>
 

อวตาร
ละทิ้ง

This works but does not consider the language (I believe the results are according to the current locale)

Related Posts ตอบกลับ มุมมอง กิจกรรม
4
ส.ค. 24
77094
1
ม.ค. 19
5824
0
มี.ค. 16
4463
Date format in Dashboard แก้ไขแล้ว
2
พ.ค. 25
1666
0
ต.ค. 23
2879