تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
9952 أدوات العرض

Hello

How can I format a date in an email template (send invoice by email for example) in Odoo 13?

It seems that this has been changed since V12. In Odoo 12 I have used the following placeholder to format the invoice date ${format_tz(object.date_invoice, tz='UTC', format='%d/%m/%Y')}

But now the same placeholder doesn't work anymore and I receive the following error:

Failed to render template using values {'format_date': <function MailTemplate._render_template.. at 0x7fa452db9c80>, 'format_datetime': <function MailTemplate._render_template.. at 0x7fa45131b048>, 'format_amount': <function MailTemplate._render_template.. at 0x7fa45131b2f0>, 'format_duration': <function MailTemplate._render_template.. at 0x7fa45131b268>, 'user': res.users(2,), 'ctx': {'lang': 'en_US', 'tz': 'Europe/Brussels', 'uid': 2, 'allowed_company_ids': [1], 'template_id': 31, 'active_model': 'mail.template', 'active_id': 31, 'active_ids': [31], 'template_preview_lang': 'en_US', 'safe': False}, 'object': account.move(86,)}

UndefinedError: 'format_tz' is undefined


All this can be tested and reproduced on odoo runbot.

Thanks in advance for any kind of help.



الصورة الرمزية
إهمال

Hi,

thanks for your answer, this is working for v14 too!

أفضل إجابة

Hi Benjamin,

try this

${object.date_invoice.strftime('%d/%m/%Y')}
الصورة الرمزية
إهمال
الكاتب

Hello Murad

Thank you for your quick reply. This is working for odoo 13

Best Regards,

Benjamin

Also working in Odoo 14, thanks!

This prints the hour in UTC, how can I print the hour in a choosen timezone?

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
ديسمبر 22
3005
0
نوفمبر 19
2928
1
ديسمبر 23
9117
4
أغسطس 24
77052
1
أكتوبر 20
7739