How to Follow/Unfollow Multiple Documents at Once

Do you have multiple documents that you would like to follow? Or maybe too many documents you were added as a follower of, creating excessive notifications you would like to stop?

By default in Odoo, you need to go through each document individually and click Follow / Unfollow, which can be a time-consuming process.

Here are two server actions that will allow you to Follow or Unfollow multiple documents at once.

To set up the Follow action, use the following steps:

  1. Go to Settings > Technical > Actions > Server Actions​ (Developer mode is required) and click on New
  2. Add the name of the action. In our case, it is “Follow Selected Orders”.
  3. Select Execute Code​.
  4. Select the Model​ where the action should be available. In our case, it is Sales Order.
  5. If you want the action to be available only for certain access groups, select the groups in the Allowed Groups​ field.
  6. In the Code​ section, add the following code:
records.message_subscribe(partner_ids=env.user.partner_id.ids)

Save the action and click the Create Contextual Action​ button. This will create the menu Follow Selected Orders in the Action menu of the Sales Order model.

Now, if you go to the Sales Order list view, select multiple sales orders, and click on Follow Selected Orders​, it will add you as a follower of the selected sales orders.

In general, when executed, this action will add the currently logged-in user as a follower of the selected documents.

The same action can be applied to other documents. The only difference in setup is the Model​. For example, for Purchase Orders, you need to select the Purchase Order model.

To create the Unfollow action, follow the same steps as above. The only change is that in the Code​ section, you need to add the following code:

records.message_unsubscribe(partner_ids=env.user.partner_id.ids)