如何解决当用户在 Odoo 10 中创建销售订单时如何禁用“您已被分配”电子邮件
在 Odoo 10 中,当用户“A”创建一个新的销售订单并将其分配给不同的销售人员(用户“B”)时,无论您对电子邮件模板/子类型/发送通知应用了什么配置,电子邮件都是自动发送给客户和销售人员(我仍然对默认情况下向客户发送内部通知电子邮件所遵循的业务逻辑感到惊讶)。
电子邮件是这种格式的众所周知的电子邮件:
"You have been assigned to SOxxxx."
更糟糕的是,电子邮件设置为“自动删除”,因此您甚至不知道您的系统向客户发送了什么(无评论)。
应覆盖 Odoo 10 CE 中的哪些模块、函数或设置以避免此类默认行为?
解决方法
覆盖 _message_auto_subscribe_notify
类的 sale.order
方法并添加到上下文 mail_auto_subscribe_no_notify。
from odoo import models,api
class SaleOrder(models.Model):
_inherit = 'sale.order'
@api.multi
def _message_auto_subscribe_notify(self,partner_ids):
""" Notify newly subscribed followers of the last posted message.
:param partner_ids : the list of partner to add as needaction partner of the last message
(This excludes the current partner)
"""
return super(SaleOrder,self.with_context(mail_auto_subscribe_no_notify=True))\
._message_auto_subscribe_notify(partner_ids)
如果在上下文中传递该键,则原始方法不会发送消息
@api.multi
def _message_auto_subscribe_notify(self,partner_ids):
""" Notify newly subscribed followers of the last posted message.
:param partner_ids : the list of partner to add as needaction partner of the last message
(This excludes the current partner)
"""
if not partner_ids:
return
if self.env.context.get('mail_auto_subscribe_no_notify'): # Here
return
# send the email only to the current record and not all the ids matching active_domain !
# by default,send_mail for mass_mail use the active_domain instead of active_ids.
if 'active_domain' in self.env.context:
ctx = dict(self.env.context)
ctx.pop('active_domain')
self = self.with_context(ctx)
for record in self:
record.message_post_with_view(
'mail.message_user_assigned',composition_mode='mass_mail',partner_ids=[(4,pid) for pid in partner_ids],auto_delete=True,auto_delete_message=True,parent_id=False,# override accidental context defaults
subtype_id=self.env.ref('mail.mt_note').id)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。