This question has been flagged
3 Replies
5351 Views

How can I add followers in created method. Like I have 2 user and in created method I have id of 2 user. So how can I add These two User ID In Message follower ids filde In Sale Order Form

Avatar
Discard
Best Answer

Hi Atchuthan, 

So how can i remove followers in python code? :)

Avatar
Discard
Best Answer

You can either add track_visibility="onchange" to those 2 user_id fields

'user_id': fields.many2one('res.users', 'Salesperson', states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True, track_visibility='onchange'),

Usually this is preferred as Odoo automatically sets the user responsible if the field is changed.

(OR)

    def create(self, cr, uid, vals, context=None):
        create_id = super(sale_order, self).create(cr, uid, vals, context)
        self.message_subscribe_users(cr, uid, [create_id], user_ids=[YOUR LIST OF USER IDS], context=context)
        return create_id

Avatar
Discard

It doesn't work Sir.