Wednesday 30 March 2022

Issue with formatting date in Qweb Odoo

Yes, This happens in odoo v12 or later versions.

In your SO, PO or any document/record date is 26/03/2022 but when you print/download pdf report it show like 26/03/2023

<span t-field="request_date_to" t-options='{"widget": "date", "format": "dd MMM Y"}'/>

Above line is printing date like : 26 Mar 2023 insted 26 Mar 2022


To fix this you need to use like this

<span t-esc="datetime.datetime.strptime(date_to, '%Y-%m-%d').strftime('%d %b %Y')"/>
<span t-esc="o.date_invoice.strftime('%d %b %Y')"/>
<span t-esc="datetime.datetime.strftime(date_to, '%d %b %Y')" /> 


It will print correct date like : 26 Mar 2022


Share:

0 comments:

Post a Comment