Odoo 中文社区

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

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

    由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

    本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

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

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

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

    Odoo 开发与实施交流
    2
    4
    2772
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 阿
      阿狸 last edited by

      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里配置好了邮件发送服务器

      关于发送邮件若有更好的方法还请罗列一下

      1 Reply Last reply Reply Quote 0
      • wjfonhand
        wjfonhand last edited by

        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,
                    }

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

        GoodERP -- Odoo China fork

        1 Reply Last reply Reply Quote 0
        • 阿
          阿狸 last edited by

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

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

          谢谢Jeff指正

          1 Reply Last reply Reply Quote 0
          • First post
            Last post