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
7749 Widoki

Is it possible to change datetime in Email Template?  

Example:
${object.date_start} here time is coming 2015-04-13 12:00:41 .
i want to add time difference +05:30 then which should come as 2015-04-13 17:30:41. 
object is used for Email Template.

2015-04-13 12:52:41

Awatar
Odrzuć
Najlepsza odpowiedź

yes, It is possible to change datetime in email template. Please use the below code sample in your email template. It will work.

${(datetime.datetime.strptime(object.date_start,'%Y-%m-%d %H:%M:%S') + relativedelta(hours=5,minutes=30)).strftime('%Y-%m-%d %H:%M:%S')} 


Above code will add +05:30 in date_start datetime.

Awatar
Odrzuć
Najlepsza odpowiedź

Hey Nilesh,

Thanks much. This really worked for me. I just replaced the body_html code at four places in the meeting invite email template, with your code and it works great.

Existing code:

${object.event_id.get_interval(object.event_id.start, 'dayname', tz=object.partner_id.tz)}

Replaced with your sample code:

${object.event_id.get_interval(((datetime.datetime.strptime(object.event_id.start,'%Y-%m-%d %H:%M:%S') + relativedelta(hours=5,minutes=30)).strftime('%Y-%m-%d %H:%M:%S')), 'dayname', tz=object.partner_id.tz)}


Basically replace "object.event_id.start" with 

"((datetime.datetime.strptime(object.event_id.start,'%Y-%m-%d %H:%M:%S') + relativedelta(hours=5,minutes=30)).strftime('%Y-%m-%d %H:%M:%S'))"

First instance is for 'dayname', the other is for 'day', next for 'month' and finally 'time'.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
lip 25
3813
6
wrz 19
11114
0
mar 15
8057
1
sty 24
12626
4
mar 23
14497