我需要向客户发送带有cc的电子邮件。但是,当我设置cc并发送邮件接收器时,收到的邮件为'to'而不显示cc人员。在odoo 10中有什么方法可以解决这个问题吗?
答案 0 :(得分:1)
在xml中:
<!--Email template -->
<record id="example_email_template" model="mail.template">
<field name="name">Vendor address : Changed</field>
<field name="email_from">${object.company_id and object.company_id.email or
''}
</field>
<field name="subject">Address Changed for ${object.name}</field>
<field name="email_to">person@mail.com
</field>
<field name="email_cc">person@mail.com</field>
<field name="lang">${object.lang}</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="auto_delete" eval="True" />
<field name="body_html">
<![CDATA[
Updated by ${(object.creating_user_id.name)}<br/>
IP Address:${(object.ip_address or '')}<br/>
<p>Updated Address:</p></br>
${(object.street or '')}<br/>
${(object.street2 or '')}<br/>
${(object.city or '')}<br/>
${(object.state_id.name or '')}<br/>
${(object.zip or '')}<br/>
${(object.country_id.name or '')}
]]>
</field>
</record>
答案 1 :(得分:1)
我找到了一个解决方案但没有为上述问题提供100%的解决方案。我还在努力.. 首先继承mail.mail并将以下代码添加到
@api.model
def send_get_mail_cc(self):
#set the email field with all the recipients
for mail_id in self.ids:
mail = self.browse(mail_id)
email_cc = []
for partner in mail.recipient_ids:
email_cc.append(partner.email)
return email_cc
然后替换&#39; def send_get_email_dict&#39;用这个
@api.multi
def send_get_email_dict(self, partner=None):
self.ensure_one()
body = self.send_get_mail_body(partner=partner)
body_alternative = tools.html2plaintext(body)
res = {
'body': body,
'body_alternative': body_alternative,
'email_to': self.send_get_mail_to(partner=partner),
'email_cc': self.send_get_mail_cc(),
}
return res
然后替换&#39; email_cc = tools.email_split(mail.email_cc),&#39;这是在'def send&#39;里面方法
email_cc=email.get('email_cc'),
然后发送邮件的所有邮件地址将在您的邮件中以cc显示(如果有人可以解决该邮件,请更正我的答案。我也在尝试)
答案 2 :(得分:1)
我需要的是将状态更改为“关闭”状态。通过拖放,电子邮件应该发送给用户。这就是我做的。
@api.constrains('stage_id')
def onchange_stage_id(self):
if self.stage_id:
stage_name= self.stage_id.name
so_no = self.env['sale.order'].search([('id', '=',self.so_no.id)]).name
task_no = self.task_no
subject_str= "Closed Task Details of "+task_no
msg = MIMEMultipart()
body_str ="""\
<html>
<head></head>
<body>
<p>Dear,<br>
Here is the closed task with reference to:"""+task_no +""". <br>
Closed under the sales order:"""+so_no +""".
</p>
</body>
</html>
"""
mail_server=self.env['ir.mail_server'].search([('name', '=',"Gmail Outgoing Server")]).id
if stage_name == "Closed":
mail=self.env['mail.mail'].create({
'email_to':"example1@gmail.com,example2@gmail.com,example3@gmail.com",
'email_cc':"example4@gmail.com,example5@gmail.com@gmail.com,example6@gmail.com@gmail.com",
'mail_server_id':mail_server,
'body_html':body_str,
'subject':subject_str,
})
mail.send()
这里我手动添加邮件地址