Repository navigation
[19.0][IMP] mail_restrict_follower_selection: enforce follower domain on programmatic subscriptions - #332
Conversation
MohamedOsman7
left a comment
There was a problem hiding this comment.
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?
| 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 | ||
| ) |
There was a problem hiding this comment.
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".
204f4ba to
2965435
Compare
5d51812 to
e7ef69d
Compare
|
Thank you for the deep review. @eLBati , @luisDIXMIT what do you think and could you review? |
|
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
e7ef69d to
2ec7371
Compare
|
@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. |
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.