You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import models, api
  5. class MailMessage(models.Model):
  6. _inherit = 'mail.message'
  7. @api.model
  8. def create(self, values):
  9. ctx = self.env.context.copy()
  10. if not ctx.get('notify_followers') and values.get('partner_ids'):
  11. partner_list = self.resolve_2many_commands(
  12. 'partner_ids', values.get('partner_ids'), fields=['id'])
  13. force_partners_to_notify = [d['id'] for d in partner_list]
  14. ctx['force_partners_to_notify'] = force_partners_to_notify
  15. return super(MailMessage, self.with_context(ctx)).create(values)
  16. @api.multi
  17. def _notify(self, force_send=False, send_after_commit=True,
  18. user_signature=True):
  19. res = super(MailMessage, self)._notify(
  20. force_send=force_send, send_after_commit=send_after_commit,
  21. user_signature=user_signature)
  22. if not self.env.context.get('notify_followers'):
  23. # Needaction only for recipients
  24. self.needaction_partner_ids = [(6, 0, self.partner_ids.ids)]
  25. return res