Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
12035 Widoki

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!

Awatar
Odrzuć
Najlepsza odpowiedź

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)'

 

Awatar
Odrzuć
Autor

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?

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

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

Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
gru 15
4530
0
lis 15
3668
3
lis 15
12892
1
kwi 16
5104
1
lis 15
6258