在 Odoo 10 中禁用自动添加合作伙伴作为关注者

Disable automatic addition of partner as follower in Odoo 10

如何停止在 Odoo 10 中自动将合作伙伴添加为关注者。每当我创建新的报价单或机会时,合作伙伴都会自动添加到关注者列表中,并且会向合作伙伴发送一封电子邮件通知,但我不知道不想。

如何防止这种情况发生?

用简单的方法就可以做到。

例如:

class sale_order(models.Model):
    _inherit="sale.order"

    @api.model
    def create(self,vals):
        res=super(sale_order,self.with_context('mail_create_nosubscribe':True)).create(vals)
        return res

如果在上下文中传递mail_create_nosubscribe True,系统将不会在消息中添加默认关注者

Odoo is supporting mainly three type of keyword in the mail message context,using that you can enable/disable processes model wise.

1.tracking_disable : 在创建和写入时,不执行 MailThread 功能(自动订阅、跟踪、post、...)

2.mail_create_nosubscribe : 在创建或 message_post 时,不要订阅 记录线程的uid

3.mail_create_nolog : 创建时,不记录自动 ' 已创建'消息

You need to just pass value in the context, system will disable above features.

这可能对您有所帮助。

没有足够的声誉 post 这作为评论,所以它必须是一个答案,很抱歉。

你的回答让我顺利进行,我稍微更改了代码以使其适合我。

class sale_order(models.Model):
    _inherit="sale.order"
    @api.model
        def create(self, vals):    
            res = super(sale_order, self.with_context(mail_create_nosubscribe=True)).create(vals)

此外,我注意到订单确认后仍在添加合作伙伴。 我用以下代码解决了这个问题:

@api.multi
    def action_confirm(self):

        return_value = super(sale_order, self.with_context(mail_create_nosubscribe=True)).action_confirm()

        for follower in self['message_follower_ids']:
            follower.unlink()

        return return_value