There is more...

When you post messages in chatter, mail will be sent to the follower. If you notice in the example of this recipe, the borrower of the book is not the follower of the records, so they will not receive the messages. If you want to send the mail notification to the borrower, you will need to add it to the borrower list. You can add the follower manually from the user interface, but if you want to add them automatically, you can use the message_subscribe() method. Take a look at the following code—when we place a book on rent, the given code will automatically add borrowers to the list of followers:

    @api.model
def create(self, vals):
res = super(LibraryBookRent, self).create(vals)
res.message_subscribe(partner_ids=[res.borrower_id.id])
return res

Similarly if you want to remove followers from the list, you can use the message_unsubscribe() method.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset