我calender.event
模塊。在那我有一個日期字段ending_date
。我想在結束日期超過當前日期時創建函數,它應該向所有員工發送通知。如何在Odoo中創建電子郵件通知功能?
在calender.event此功能繼承文件
def send_birthday_email(self, cr, uid, ids=None, context=None):
sobj = self.pool.get('calendar.event').browse(cr,uid,ids,context=context)
ir_model_data = self.pool.get('ir.model.data')
template_obj = self.pool.get('email.template')
cc_text = ''
if sobj.attendee_ids:
for cc_obj in sobj.attendee_ids:
if cc_obj.email:
cc_text += cc_obj.email + ','
for rec in sobj:
template_id = ir_model_data.get_object_reference(cr,uid,'calander_extended', 'calendar_notify')[1]
self.pool.get('email.template').write(cr,uid,template_id,{'email_to' : cc_text,})
self.pool.get('email.template').send_mail(cr,uid,template_id,rec.id,force_send=True,context=context)
return True
這是它
<?xml version="1.0"?>
<openerp>
<data>
<record id="calendar_notify" model="email.template">
<field name="name">Email Notification</field>
<field name="email_from">${object.event_id.user_id.email or ''}</field>
<field name="subject">${object.event_id.name}</field>
<field name="model_id" ref="calander_extended.model_calendar_event"/>
<field name="email_to" >${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.email else object.email|safe)}</field>
<field name="partner_to">${object.partner_id and object.partner_id.email and object.partner_id.email==object.email and object.partner_id.id or False }</field>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>${object.event_id.name}</title>
<style>
span.oe_mail_footer_access {
display:block;
text-align:center;
color:grey;
}
</style>
</head>
<body>
<div style="border-radius: 2px; max-width: 1200px; height: auto;margin-left: auto;margin-right: auto;background-color:#f9f9f9;">
<div style="height:auto;text-align: center;font-size : 30px;color: #8A89BA;">
<strong>${object.event_id.name}</strong>
</div>
</div>
</body>
</html>
]]>
</field>
</record>
</data>
</openerp>
書面當我通過點擊按鈕,然後它沒有得到任何錯誤。但調用該函數電子郵件模板沒有獲取郵件還向與會者
我想怎麼寫funtion爲 –