Skip to Content
Menu
This question has been flagged
4 Replies
10717 Views

I want to print date in qweb report in odoo10 like 13th january 2020. Please help.

Avatar
Discard
Best Answer

Hi,

Try this:

<t t-esc="line['date'].strftime('%d-%B -%Y')"/>


UPDT: try this :  

<t t-esc="line['date'].strftime('%d th %B %Y')"/>

Thanks

Avatar
Discard

What about if I want to change date format when I export data as csv file from tree view ?

we know that we can set format in From General settings > Translation but when we export the records in csv file the format is not the same as the translation we setted. Do you know How can we do that ?

Best Answer

Hi,

There are two way to format date/datetime.

1) By global setting by going to Settings > Translations > Languages, select your language and in language form, you can set datetime format.

2) In report xml, manually you can format field value:

<p t-esc="datetime.datetime.now().strftime('%Y-%m-%d')" t-options="{'widget': 'date'}" class="m-0"/>

<t t-esc='value' t-options="{'widget': 'datetime'}" />

For more, you can investigate in odoo base code.

I hope this will help you.


Thanks

Avatar
Discard

What about if I want to change date format when I export data as csv file from tree view ?

we know that we can set format in From General settings > Translation but when we export the records in csv file the format is not the same as the translation we setted. Do you know How can we do that ?

Best Answer

The best way is to use odoo utilities. Adding code in a PDF report is not a good idea. In odoo 14 and above, you can set the widget and its options as follow:

So, just set the widget and format then odoo does the best.


Avatar
Discard
Author Best Answer

Hi,

Thanks for your response.

I tried  this <t t-esc="line['date'].strftime('%d-%B -%Y')"/>, but using this, date will displayed like 13 january 2020. I want 13th january 2020.

Avatar
Discard

see the updated answer, <t t-esc="line['date'].strftime('%d th %B %Y')"/>