Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to change the date format when loading a mail template?

By
Juan Formoso
on 1/26/15, 10:39 AM 1,927 views

I've created a mail template (module email_template), I load it before sending the mail (though the email.compose.message wizard) and it's working perfect.

However, in the template I'm showing a field of type date, and it's showing up with the format "%Y-%m-%d %H:%M". The problem is that that's not the date format of my language, I need "%d-%m-%Y %H:%M".

I've tried with ${my_date|dateformat("%d-%m-%Y %H:%M")}, but I've gotten an error. How can I achieve the new format?

Thank you in advance!

0

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2983
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 1/26/15, 4:32 PM

Hello,

Have you try with tz_format ? From memory, it exists since saas-3 (So, it will not work in V7 :( ).

Example;

${format_tz(object.name,object.employee_id.address_id.tz or 'Europe/Brussels','%m/%d/%Y %H:%M')}

Info:

function format_tz(datetime, tz, format)}

datetime is required:
    Be aware that this will only work with datetime. Not a string, or a date    

tz is optional, function uses:
    - tz param
    - current user tz 
    - UTC

format is optional, function uses:
    - format param
    - format on lang in context
    - '%B-%d-%Y %I-%M %p (tz)'

 

Thank you! You've explained it very well, but it's not working, it produces an error when the template is rendered. I'm using OpenERP7, does that work on it?

Juan Formoso
on 1/27/15, 10:47 AM

Sorry, it's only since Saas-3, so it will not works... You can use an ugly hack with your date (spliting the string)... Euro Date = ${"%s/%s/%s" % (object.date_order[8:11], object.date_order[5:7], object.date_order[0:4])} Sorry, no more idea

Jérémy Kersten (jke)
on 1/27/15, 11:24 AM

FYI: function format_tz(datetime, tz, format)}

Jérémy Kersten (jke)
on 1/6/16, 9:12 AM
-1
Erwin van der Ploeg
On 1/26/15, 12:44 PM

Somdone from odoo told me it not possible to change format. It is fixed in YYYY-MM-DD. Not implemented by them. 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 1/26/15, 10:39 AM
Seen: 1927 times
Last updated: 3/16/15, 8:10 AM