2018-04-04 10:19:13 +02:00
|
|
|
# Copyright (C) 2018 Creu Blanca
|
|
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
|
2020-03-04 16:27:05 +01:00
|
|
|
from odoo import models
|
2018-04-04 10:19:13 +02:00
|
|
|
from odoo.tools.safe_eval import safe_eval
|
|
|
|
|
|
|
|
|
|
|
|
class MailFollowers(models.Model):
|
2020-03-09 15:10:18 +01:00
|
|
|
_inherit = "mail.followers"
|
2018-04-04 10:19:13 +02:00
|
|
|
|
2020-03-09 15:10:18 +01:00
|
|
|
def _add_followers(
|
|
|
|
self,
|
|
|
|
res_model,
|
|
|
|
res_ids,
|
|
|
|
partner_ids,
|
|
|
|
partner_subtypes,
|
|
|
|
channel_ids,
|
|
|
|
channel_subtypes,
|
|
|
|
check_existing=False,
|
|
|
|
existing_policy="skip",
|
|
|
|
):
|
2018-04-04 10:19:13 +02:00
|
|
|
domain = self.env[
|
2020-03-09 15:10:18 +01:00
|
|
|
"mail.wizard.invite"
|
2018-04-04 10:19:13 +02:00
|
|
|
]._mail_restrict_follower_selection_get_domain()
|
2020-03-09 15:10:18 +01:00
|
|
|
partners = self.env["res.partner"].search(
|
|
|
|
[("id", "in", partner_ids)] + safe_eval(domain)
|
2018-04-04 10:19:13 +02:00
|
|
|
)
|
2020-03-04 16:27:05 +01:00
|
|
|
_res_ids = res_ids.copy() or [0]
|
|
|
|
new, update = super()._add_followers(
|
2020-03-09 15:10:18 +01:00
|
|
|
res_model,
|
|
|
|
res_ids,
|
|
|
|
partners.ids,
|
|
|
|
partner_subtypes,
|
|
|
|
channel_ids,
|
|
|
|
channel_subtypes,
|
|
|
|
check_existing=check_existing,
|
|
|
|
existing_policy=existing_policy,
|
2020-03-04 16:27:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
for res_id in _res_ids:
|
|
|
|
if res_id not in new:
|
|
|
|
new.setdefault(res_id, list())
|
|
|
|
return new, update
|