2019-12-06 11:49:27 +01:00
|
|
|
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>)
|
|
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
|
|
|
|
from odoo import models
|
2021-05-07 16:46:45 +02:00
|
|
|
from odoo.tools import config
|
2019-12-06 11:49:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
class MailThread(models.AbstractModel):
|
|
|
|
_inherit = "mail.thread"
|
|
|
|
|
|
|
|
def _notify_compute_recipients(self, message, msg_vals):
|
2021-05-07 16:42:26 +02:00
|
|
|
"""Compute recipients to notify based on subtype and followers. This
|
|
|
|
method returns data structured as expected for ``_notify_recipients``."""
|
2021-05-07 16:46:45 +02:00
|
|
|
test_condition = config["test_enable"] and not self.env.context.get(
|
|
|
|
"test_optional_follow_notification"
|
|
|
|
)
|
2019-12-06 11:49:27 +01:00
|
|
|
recipient_data = super()._notify_compute_recipients(message, msg_vals)
|
2021-05-07 16:46:45 +02:00
|
|
|
if test_condition:
|
|
|
|
return recipient_data
|
2020-07-09 11:07:51 +02:00
|
|
|
if "notify_followers" in self.env.context and not self.env.context.get(
|
|
|
|
"notify_followers", False
|
|
|
|
):
|
2019-12-06 11:49:27 +01:00
|
|
|
# filter out all the followers
|
|
|
|
pids = (
|
|
|
|
msg_vals.get("partner_ids", [])
|
|
|
|
if msg_vals
|
|
|
|
else message.sudo().partner_ids.ids
|
|
|
|
)
|
2022-03-09 16:02:48 +01:00
|
|
|
recipient_data = [d for d in recipient_data if d["id"] in pids]
|
2019-12-06 11:49:27 +01:00
|
|
|
return recipient_data
|