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
|
|
|
|
2016-10-24 11:46:07 +02:00
|
|
|
from odoo import models, api
|
2016-05-25 16:03:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MailMessage(models.Model):
|
|
|
|
_inherit = 'mail.message'
|
|
|
|
|
|
|
|
@api.model
|
|
|
|
def create(self, values):
|
|
|
|
ctx = self.env.context.copy()
|
|
|
|
if not ctx.get('notify_followers') and values.get('partner_ids'):
|
|
|
|
partner_list = self.resolve_2many_commands(
|
|
|
|
'partner_ids', values.get('partner_ids'), fields=['id'])
|
2019-11-29 16:01:16 +01:00
|
|
|
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-11-29 16:01:16 +01:00
|
|
|
def _notify(self, record, msg_vals, force_send=False,
|
|
|
|
send_after_commit=True, model_description=False,
|
|
|
|
mail_auto_delete=True):
|
|
|
|
res = super()._notify(
|
|
|
|
record, msg_vals, force_send=force_send,
|
|
|
|
send_after_commit=send_after_commit,
|
|
|
|
model_description=model_description,
|
|
|
|
mail_auto_delete=mail_auto_delete)
|
2017-10-20 17:42:56 +02:00
|
|
|
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 = [
|
|
|
|
(6, 0, self.env.context.get('force_partners_to_notify'))]
|
2016-10-24 11:46:07 +02:00
|
|
|
return res
|