Disable automatic addition of partner as follower in Odoo 10

冷暖自知 提交于 2021-02-18 08:38:53

问题


How can I stop automatic addition of partners as followers in Odoo 10. Whenever I create a new quotation or opportunity, the partner is automatically added to the followers list and an email notification is send to the partner which I don't want.

How can I prevent this from happening?


回答1:


You can do it using simple method.

Ex:

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

If you pass mail_create_nosubscribe True in the context, system will not add default followers in the message.

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 : At create and write, perform no MailThread features (auto subscription, tracking, post, ...)

2.mail_create_nosubscribe : At create or message_post, do not subscribe uid to the record thread

3.mail_create_nolog : At create, do not log the automatic ' created' message

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

This may help you.




回答2:


Not enough reputation to post this as a comment, so it had to be an answer, sorry for that.

You answer set me well on my way, I changed the code a little bit to make it work for me.

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)

In addition, I noticed that the partner was still being added upon order confirmation. I resolved that with the following code:

@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


来源:https://stackoverflow.com/questions/45006235/disable-automatic-addition-of-partner-as-follower-in-odoo-10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!