Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

【分享】在OE里用函数发邮件



  • def send_the_mail(self, cr, uid, ids, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; active_model_pool = self.pool.get(&#039;mail.thread&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; post_values = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;subject&#039;: u&#039;该开会了&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;body&#039;: u&#039;开会时间到了&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;parent_id&#039;: &#91;],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;partner_ids&#039;: [9],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;attachment_ids&#039;: &#91;],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;attachments&#039;: &#91;],<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; res_id=[0]<br />&nbsp; &nbsp; &nbsp; &nbsp; subtype = &#039;mail.mt_comment&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; msg_id = active_model_pool.message_post(cr, uid, res_id, type=&#039;comment&#039;, 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,
                }

    发邮件不是这样子的么?
    您这个是发消息



  • [quote author=Jeff link=topic=16642.msg29106#msg29106 date=1412669752]

    发邮件不是这样子的么?
    您这个是发消息
    [/quote]
    总觉得我这么写有问题,果然有问题。。。

    谢谢Jeff指正