如何在odoo中为电子邮件模板设置其他消息? [英] how to set a different message for an email template in odoo?

查看:117
本文介绍了如何在odoo中为电子邮件模板设置其他消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义模块,并使用日历对象创建了一个事件,其代码如下

I created a custom module and had used the calendar object to create an event and the code is as follows

def create_calender_event(self,cr,uid,ids,context=None):
    calendar_obj = self.pool.get('calendar.event')      
    for rec in self.browse(cr,uid,ids,context=context):
        if rec.action:
            for rec_res in rec.action:
                calendar_obj.create(cr,uid,{'name' : rec_res.act_ion,
                    'user_id' : rec_res.asgnd_to.id,
                    'start_date' : rec_res.due_date,
                    'stop_date' : rec_res.due_date,
                    'allday' : True,
                    'partner_ids' : [(6,0, [rec_res.asgnd_to.partner_id.id])]
                },context=context)

这将在相应用户的日历中创建一个事件,但它使用默认模板消息.

This will create a event in respective user's calendar, but it uses default template message.

如何用自定义消息替换日历邀请模板消息?

How can i replace the calendar invitation template message by custom message ?

推荐答案

您可以从py文件中这样做

you can do like this from py file

1)获取template_id并浏览对象
2)模板主体将存储在"body_html"字段中
3)将body_html字段存储在一个变量中,可以说: old_body
4)然后将您的自定义代码添加到模板的"body_html"字段中,并使用上述temlate_id将值写入模板中
5)使用send方法发送邮件
6)然后将 old_body 值写回到模板中.

1) get the template_id and browse the object
2) the template body will be stored in 'body_html' field
3) store the body_html field in one variable, lets say: old_body
4) then add your customized code to template's 'body_html' field and write the values into template using the above temlate_id
5) send the mail, using send method
6) then write back the old_body value back to the template.

仅出于想法,请参考此....

just for idea, refer this....

template_id = template_pool.search(cr,uid,[('name','= ilike',template_name)])
如果template_id:
template_obj = template_pool.browse(cr,uid,template_id)
正文= template_obj.body_html
body_old =身体
计数= 0

正文+ ="

对于%s学习笔记PDF 单击此处

template_id = template_pool.search(cr,uid,[('name','=ilike',template_name)])
if template_id:
template_obj = template_pool.browse(cr, uid, template_id)
body = template_obj.body_html
body_old = body
count = 0

body += "

For %s Study Notes PDF Click here

这篇关于如何在odoo中为电子邮件模板设置其他消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆