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

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
أكتوبر 24
1117
0
أغسطس 23
2488
1
ديسمبر 22
2206
0
يوليو 21
2564
4
أغسطس 17
13033