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

The date in my Sales Order is currently showing as:

Fecha: 21/11/2014 16:59:15

I want to show something like this:

Fecha: Surco, 21 de Noviembre del 2014

I tried using t-esc with strftime but that doesn't work:

<span t-esc="o.date_order.strftime('%Y')" />

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

Hello Cesar Bustios Benites

try this code may be helpfull.

<span t-field="o.date_order" t-field-options='{"format": "d MMMM y"}'/>

also use this code

<span t-field="o.date_order" t-field-options="{&quot;format&quot;: &quot;yyyy-MM-dd&quot;}" />

Update:

I thought that t-field-options could only be applied to t-field.

<span t-field="o.commencement_date"

t-field-options="{&quot;format&quot;: &quot;dd/MM/yy&quot;}"></span

Updated:

<span t-esc="o.order_date" t-options='{"widget": "date"}'/>


if you find this answer helpful, please give me a thumbs up vote

Regards,

Ankit H Gandhi

 

อวตาร
ละทิ้ง

<span t-esc="o.order_date" t-options='{"widget": "date"}'/> is correct for version 12 qweb reports it works thanks

In Odoo 11 works fine too! Thanks

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

try this , change date format as required , refer: Python Standard Library - time , 

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

อวตาร
ละทิ้ง
ผู้เขียน

Thank you @Sajin, I'm getting "Uncaught SyntaxError: Unexpected end of input"

ผู้เขียน

Sorry, my bad. This is the correct answer :-)

ผู้เขียน

Although I'm using Spanish as my language, I'm getting this: "Surco, 21 de November del 2014". How can I make months show in Spanish?

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

Hi César. If you are getting an error, please specify what error it is. Otherwise I'm going to assume that your date format is merely incomplete. Try this:

<span t-esc="o.date_order.strftime('%A, %d de %B del %Y')" />

อวตาร
ละทิ้ง
ผู้เขียน

Hello @Kelly, thank you for your answer. Yes I'm getting an error: "Uncaught SyntaxError: Unexpected end of input"

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

in odoo10

it prints mm-dd-yyyy format of date order

<span t-field="o.date_order" t-options="{&quot;format&quot;: &quot;MM-dd-yyyy&quot;}" />

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

model inside default field date

current_date = fields.Date(default=time.strftime("%Y-%m-%d"))

report xml

<span t-field="o.current_date"/>

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

For date and time display in formate like Jun 20, 2017 11:05 AM in Qweb Report.
"<sapn t-esc="datetime.datetime.strptime(o.create_date, '%Y-%m-%d %H:%M:%S').strftime('%b %d,%Y %H:%M %p')"/>"

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

I hope the Below link should be helpful for you

http://stackoverflow.com/questions/27071767/how-can-i-format-date-in-odoo-8-qweb-report

อวตาร
ละทิ้ง