2016-05-25 16:03:38 +02:00
|
|
|
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
2019-11-29 16:01:16 +01:00
|
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
2016-05-25 16:03:38 +02:00
|
|
|
|
2019-12-06 11:37:20 +01:00
|
|
|
from odoo import api, models
|
2016-05-25 16:03:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MailMessage(models.Model):
|
2019-12-06 11:37:20 +01:00
|
|
|
_inherit = "mail.message"
|
2016-05-25 16:03:38 +02:00
|
|
|
|
|
|
|
@api.model
|
|
|
|
def create(self, values):
|
|
|
|
ctx = self.env.context.copy()
|
2019-12-06 11:37:20 +01:00
|
|
|
if not ctx.get("notify_followers") and values.get("partner_ids"):
|
2016-05-25 16:03:38 +02:00
|
|
|
partner_list = self.resolve_2many_commands(
|
2019-12-06 11:37:20 +01:00
|
|
|
"partner_ids", values.get("partner_ids"), fields=["id"]
|
|
|
|
)
|
|
|
|
ctx["force_partners_to_notify"] = [d["id"] for d in partner_list]
|
2016-05-25 16:03:38 +02:00
|
|
|
return super(MailMessage, self.with_context(ctx)).create(values)
|
2016-10-24 11:46:07 +02:00
|
|
|
|
|
|
|
@api.multi
|
2019-12-06 11:37:20 +01:00
|
|
|
def _notify(
|
|
|
|
self,
|
|
|
|
record,
|
|
|
|
msg_vals,
|
|
|
|
force_send=False,
|
|
|
|
send_after_commit=True,
|
|
|
|
model_description=False,
|
|
|
|
mail_auto_delete=True,
|
|
|
|
):
|
2019-11-29 16:01:16 +01:00
|
|
|
res = super()._notify(
|
2019-12-06 11:37:20 +01:00
|
|
|
record,
|
|
|
|
msg_vals,
|
|
|
|
force_send=force_send,
|
2019-11-29 16:01:16 +01:00
|
|
|
send_after_commit=send_after_commit,
|
|
|
|
model_description=model_description,
|
2019-12-06 11:37:20 +01:00
|
|
|
mail_auto_delete=mail_auto_delete,
|
|
|
|
)
|
|
|
|
if self.env.context.get("force_partners_to_notify"):
|
2016-10-24 11:46:07 +02:00
|
|
|
# Needaction only for recipients
|
2017-10-20 17:42:56 +02:00
|
|
|
self.needaction_partner_ids = [
|
2019-12-06 11:37:20 +01:00
|
|
|
(6, 0, self.env.context.get("force_partners_to_notify"))
|
|
|
|
]
|
2016-10-24 11:46:07 +02:00
|
|
|
return res
|