gpt4 book ai didi

email - 创建项目问题时如何发送电子邮件通知?奥多 9

转载 作者:行者123 更新时间:2023-12-03 02:37:55 25 4
gpt4 key购买 nike

您好,我创建了新问题,但无法收到电子邮件通知。

你是怎么做到的?

已编辑

我在下面添加了一些代码,但我无法从自己那里获取 message_follower_ids 来发送电子邮件。

class project_issue(osv.osv):
_inherit = 'project.issue'
_columns = {}

def create(self, cr, uid, vals, context=None):
res = super(project_issue, self).create(cr, uid, vals, context=context)
return res

已更新

我更新了代码以获取关注者电子邮件地址并成功发送邮件,但他们转到一封电子邮件。

它的 object.name 是合作伙伴的名称,但我希望它是问题名称。

def create(self, cr, uid, vals, context=None):
res = super(project_issue, self).create(cr, uid, vals, context=context)
issue = self.pool.get('project.issue').browse(cr, uid, res, context=context)

template = self.pool.get('ir.model.data').get_object(cr, uid, 'customized_project', 'email_template_customer_auto')

for follower in issue.message_partner_ids:
self.pool.get('mail.template').send_mail(cr, uid, template.id, follower.id, force_send=True, raise_exception=True, context=context)

这是一个电子邮件模板

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!--Email template-->
<record id="email_template_customer_auto" model="mail.template">
<field name="name">Send email notification for issue creation</field>
<field name="email_from">${object.company_id and object.company_id.email or ''}</field>
<field name="subject">New Issue created ${object.name}</field>
<field name="email_to">${object.email|safe}</field>
<field name="model_id" ref="model_project_issue"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.lang}</field>
<field name="body_html"><![CDATA[
"""
Write here a body of email using HTML tag.....
"""
]]>
</field>
</record>
</data>
</openerp>

最佳答案

我找到了在创建问题时发送电子邮件的解决方案

from openerp.osv import osv, fields
import logging

class project_issue(osv.osv):
_inherit = 'project.issue'
_columns = {}

issue = ''
templtate = ''

def create(self, cr, uid, vals, context=None):
res = super(project_issue, self).create(cr, uid, vals, context=context)

self.issue = self.pool.get('project.issue').browse(cr, uid, res, context=context)

manager = self.issue.project_id.user_id.partner_id.id

assignTo = self.issue.user_id.partner_id.id

post_vars = {
'subject': ("Issue {} has been created".format(self.issue.name)),
'body': ("Issue {} has been created".format(self.issue.name)),
'partner_ids': [(4, manager)],
}
thread_pool = self.pool.get('mail.thread')
thread_pool.message_post(cr, uid, False,
context=context,
**post_vars)
return res

关于email - 创建项目问题时如何发送电子邮件通知?奥多 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44880324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com