我创建了一个自定义模块并使用日历对象创建了一个事件,代码如下
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)
这将在相应用户的日历中创建一个事件,但它使用默认模板消息。
如何用自定义消息替换日历邀请模板消息?
最佳答案
你可以从 py 文件中这样做
1) 获取template_id并浏览对象
2) 模板正文将存储在'body_html'字段中
3)将 body_html 字段存储在一个变量中,比方说:old_body
4) 然后将您的自定义代码添加到模板的“body_html”字段,并使用上面的 temlate_id 将值写入模板
5)发送邮件,使用send方法
6) 然后将old_body值写回模板。
仅供引用,请引用此...
template_id = template_pool.search(cr,uid,[('name','=ilike',template_name)])
如果 template_id:
template_obj = template_pool.browse(cr, uid, template_id)
body = template_obj.body_html
body_old = body
计数 = 0
body += "
%s 学习笔记 PDF 点击此处
"%(url['subject'],url['url'])template_pool.write(cr, uid, template_id, {'body_html':body})
template_pool.send_mail(cr, uid, template_id[0], record.id)
template_pool.write(cr, uid, template_id, {'body_html': body_old})
关于odoo - 如何在odoo中为电子邮件模板设置不同的消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31446205/