콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
9293 화면

Hello

I made a custom module that load data from email.template but the problem is that data not rendering and just showing as code like ${object.date} instead of showing date. so any one can say how i can handle this, what should i add to my custom module to get able to render email template objects?

i get data from email.template with a simple way like below code

template_id = fields.Many2one(
'email.template',
string='Template',
track_visibility='onchange',)
and then getting the body value with onchange like below

self.note = self.template_id.body_html

Thanks :)

아바타
취소
베스트 답변

Hi Berctain,

To render email template object in your module you need to follow bellow steps:

ir_model_obj = self.env['ir.model.data']

# browse template reference from model data

template_browse = ir_model_obj.get_object_reference('module_name', 'email_template_id')[1] 

# browse email template 

email_template_obj = self.env['mail.template'].browse(template_browse)

# Generate email template for specific record

values = email_template_obj.generate_email(res_id) # it is to generate email for specific object record


Refer: https://www.odoo.com/forum/help-1/question/correct-way-to-e-mail-custom-html-record-in-function-96570

https://www.odoo.com/forum/help-1/question/qweb-templating-python-side-access-survey-user-input-model-on-survey-template-using-t-field-93882


Hope it will useful for you..

아바타
취소
작성자

Hello

Note worked.

do these are miss typed or some thing?

'email_template_id' instead of 'email_template'

or

self.env['mail.template'] instead of self.env['email.template']

and the first error i get is this >> the External id not found res_cores_int.email_template_id even when i change it too email.template its same

res.core.int is my module name

관련 게시물 답글 화면 활동
0
10월 24
1106
0
8월 23
2475
1
12월 22
2194
0
7월 21
2552
4
8월 17
13019