I want to print date in qweb report in odoo10 like 13th january 2020. Please help.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
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
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 ?
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
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 ?
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.
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.
see the updated answer, <t t-esc="line['date'].strftime('%d th %B %Y')"/>
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up