【分享】在OE里用函数发邮件
- 
def send_the_mail(self, cr, uid, ids, context=None):<br />        active_model_pool = self.pool.get('mail.thread')<br />        post_values = {<br />            'subject': u'该开会了',<br />            'body': u'开会时间到了',<br />            'parent_id': [],<br />            'partner_ids': [9],<br />            'attachment_ids': [],<br />            'attachments': [],<br />        }<br />        res_id=[0]<br />        subtype = 'mail.mt_comment'<br />        msg_id = active_model_pool.message_post(cr, uid, res_id, type='comment', subtype=subtype, context=context, **post_values)
其中, 'subject','body',分别为标题跟内容,partner_ids为res.user里的partner_id,发送给partner_id对应的联系人,前提是该user填写了邮箱地址,大前提是在OE里配置好了邮件发送服务器
关于发送邮件若有更好的方法还请罗列一下 - 
ctx = dict(context)
ctx.update({
'default_model': 'stock.picking.out',
'default_res_id': ids[0],
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
})
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(compose_form_id, 'form')],
'view_id': compose_form_id,
'target': 'new',
'context': ctx,
}
发邮件不是这样子的么?
您这个是发消息