There's more...

Posting messages can be done using the following method:

obj.message_post(body="Body text", subject="Subject", subtype="mt_note") 

The subject and subtype are optional.

Followers can be either partners or message channels. To add followers, use the following:

obj.message_subscribe(partner_ids=..., channel_ids=..., subtype_ids=[]) 

The subtype_ids argument is optional, and allows you to subscribe specific subtypes. If not provided, the defaults defined in the subtypes will be used.

Sometimes, we want to add a user as a follower. A user is also a partner, so user.partner_id should be used for this. However, the following specific method is also provided for this:

obj.message_subscribe_users(user_ids, subtype_ids=[])

It is reasonable to expect to be able to post messages or follow documents, even if the connected user has no write access to them. Special security logic is implemented to allow this, and these particular operations are performed with the Administrator user, through the sudo() ORM method.

Message subtypes can be managed in the Settings top menu by navigating to the Technical | Email | Subtypes menu item. There, we can inspect the existing subtypes and customize them. Description is the text displayed in the message, and the Default field indicates if the subtype is subscribed by default for the new followers.

Subtypes support an inheritance mechanism. It is, for example, used by projects to allow the followers to automatically subscribe events on tasks and issues, such as Task Opened. This is done using the fields in the Auto Subscription area of the subtype:

  • Parent is the related subtype to be automatically subscribed. For the project.project Task Opened, this would be the project.task Task Opened.
  • Relation Field is the field in the related model to use. For a project.task subtype, this is project_id, for the Project to inherit subscription from.

Odoo also supports Activities in a fashion similar to mail messages. Activities can be used to serve as reminders for actions related to a record that need to be performed by a user. In our library example, we can envision the creation of an activity record to repair a book that has been returned in bad condition by a user. To allow managing activities on a model, you need to inherit from mail.activity.mixin.

To integrate activities in the form view of the record, in the div of the chatter, you need to add the activity_ids with the mail_activity widget, as follows:

<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
</div>
..................Content has been hidden....................

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