Skip to content

[19.0][IMP] mail_restrict_follower_selection: enforce follower domain on programmatic subscriptions - #332

Open
CRogos wants to merge 1 commit into
OCA:19.0from
c4a8-odoo:19.0-fix-mail_restrict_follower_selection-message_subscribe
Open

CRogos wants to merge 1 commit into
OCA:19.0from
c4a8-odoo:19.0-fix-mail_restrict_follower_selection-message_subscribe

Conversation

@CRogos

@CRogos CRogos commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

The 18.0 version at least filtered the chatter's suggested recipients through an override of the core hook _message_add_suggested_recipient. That hook no longer exists in Odoo 19, and the override was dropped without replacement, so the README claim that the module "disables the option to automatically add followers that do not meet the domain" is currently untrue. Any model that auto-subscribes its partner (CRM leads, sale orders, projects, tickets) shows the same behavior.

Recommended fix:

Override message_subscribe on mail.thread in the module and drop partners that fail the domain, keeping the existing no_restrict_follower context key as an escape hatch.

@OCA-git-bot OCA-git-bot added series:19.0 mod:mail_restrict_follower_selection Module mail_restrict_follower_selection labels Nov 2, 2026

@MohamedOsman7 MohamedOsman7 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I also noticed while testing:
This is not new, but now that message_subscribe() filters anyway, the wizard filter seems redundant, and it doesn't have the "current user is always allowed" exception. So "Follow" works for me but adding myself via "Add Followers" doesn't. Maybe just drop the wizard filter so there's only one rule?

Comment on lines +14 to +30
def message_subscribe(self, partner_ids=None, subtype_ids=None):
"""Drop partners that do not meet the configured follower domain.
Many models subscribe partners programmatically (customer of a ticket,
lead or order, recipients of a posted message, senders of incoming
mails, ...) without going through the followers wizard, so the
restriction has to be enforced here to be effective.
Pass ``no_restrict_follower`` in the context to bypass the check.
"""
if partner_ids and not self.env.context.get("no_restrict_follower"):
partner_ids = self._mail_restrict_follower_selection_filter_partners(
partner_ids
)
return super().message_subscribe(
partner_ids=partner_ids, subtype_ids=subtype_ids
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignees still get through: If i set a user outside the domain as Assignee on a task, they will end up as a follower. Odoo adds those via _message_auto_subscribe -> _insert_followers (https://github.com/odoo/odoo/blob/19.0/addons/mail/models/mail_thread.py#L4845) directly, so it never hits message_subscribe( ). To reproduce (tested):

  • Set the system parameter mail_restrict_follower_selection.domain.project.task = [('category_id.name', '=', 'Employees')].
  • With an internal user without the "Employees" tag: create a task and set the user in Assignees.
  • The User is now a follower of the task, although they don't match the domain.

@CRogos Or this is not a problem? (probably since assignees should follow their tasks?). Because the README says "enforced on every follower addition".

@CRogos

CRogos commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the deep review.
The new implementation now restricts also the "Follow" button if the current person does not matches the allow list. It also takes care that no one gets automatically added, when they match the restricted domain. This is in conflict with the description change in #357 .

@eLBati , @luisDIXMIT what do you think and could you review?

@luisDIXMIT

Copy link
Copy Markdown
Contributor

Hi @CRogos , I’m not sure that in 19.0 partners such as the customer of a sale order are automatically subscribed. I tested it on runbot. Could you confirm this? Also, the description says the applied solution is to override the message_subscribe method, but from the comments I understand that approach is outdated and you went with a different one.

…ogrammatic subscriptions and update documentation

Assisted-by: Claude Fable 5.1
@CRogos
CRogos force-pushed the 19.0-fix-mail_restrict_follower_selection-message_subscribe branch from e7ef69d to 2ec7371 Compare November 20, 2026 11:51
@CRogos

CRogos commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@luisDIXMIT you are right. I've changed the text a little bit.

I can definitely can confirm it for the enterprise helpdesk tickets, and could also check if for the sales order responsible, but not the customer.

I think message_subscribe is still the method that is called and this method is calling _insert_followers which is now changed. I think the comment/tests can stay to make sure that use case is working. But if you want to suggest any explicit change, I'll have a look on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:mail_restrict_follower_selection Module mail_restrict_follower_selection series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants