跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

  1. 主页
  2. 版块
  3. Odoo 开发与实施交流
  4. 【分享】在OE里用函数发邮件

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

已定时 已固定 已锁定 已移动 Odoo 开发与实施交流
4 帖子 2 发布者 3.1k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • 阿 离线
    阿 离线
    阿狸
    写于 最后由 编辑
    #1
    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 条回复 最后回复
    0
    • wjfonhandW 离线
      wjfonhandW 离线
      wjfonhand
      写于 最后由 编辑
      #2

      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 条回复 最后回复
      0
      • 阿 离线
        阿 离线
        阿狸
        写于 最后由 编辑
        #3

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

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

        谢谢Jeff指正

        1 条回复 最后回复
        0

        • 登录

        • 没有帐号? 注册

        • 登录或注册以进行搜索。
        • 第一个帖子
          最后一个帖子
        0
        • 版块
        • 标签
        • 热门
        • 用户
        • 群组