2017-07-10 49 views

回答

2

您可以使用簡單的方法。

例:

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真的背景下,系統將不會在消息中添加默認的追隨者。

Odoo在郵件消息上下文中主要支持三種類型的關鍵字,使用該功能可以啓用/禁用模型明智的過程。

1.tracking_disable:在創建並寫入,執行不MailThread功能(自動訂閱,跟蹤後,...)

2.mail_create_nosubscribe:在創建或message_post,做不訂閱 UID的紀錄線程

3.mail_create_nolog:在創造,不用登錄自動「 創建」消息

您只需在上下文中傳遞值,系統將禁用上述功能中的 。

這可能會幫助你。

0

沒有足夠的聲望發佈此評論,所以它必須是一個答案,對不起。

你的回答讓我對自己的方式感到滿意,我改變了一些代碼以使它適合我。

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