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
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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')"/>
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký