如何在Odoo 8 QWeb报告中格式化日期?

Cés*_*sar 8 report openerp qweb

我的销售订单中的日期当前显示为:

Fecha: 21/11/2014 16:59:15 
Run Code Online (Sandbox Code Playgroud)

我想展示这样的东西:

Fecha: Surco, 21 de Noviembre del 2014
Run Code Online (Sandbox Code Playgroud)

我试着用t-escstrftime,但不工作:

<span t-esc="o.date_order.strftime('%Y')" />
Run Code Online (Sandbox Code Playgroud)

小智 17

尝试使用:

<span t-field="o.date_order" t-field-options='{"format": "d MMMM y"}'/>
Run Code Online (Sandbox Code Playgroud)

结果:2014年11月21日


Cés*_*sar 8

看起来o.date_order它不是一个datetime对象而是一个字符串.使用该time模块是要走的路:

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