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.

46 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 ACSONE SA/NV <https://acsone.eu>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import models, api
  5. from odoo.tools.translate import _
  6. class MailNotification(models.Model):
  7. _inherit = 'res.partner'
  8. @api.multi
  9. def _notify_by_email(
  10. self, message, force_send=False, send_after_commit=True,
  11. user_signature=True
  12. ):
  13. # we need to save the complete list of partners because
  14. # _message_notification_recipients builds recipients
  15. # grouped by users groups. Thus get_additional_footer would get a
  16. # partial list of recipients
  17. return super(
  18. MailNotification, self.with_context(notified_partners=self)
  19. )._notify_by_email(
  20. message, force_send=force_send,
  21. send_after_commit=send_after_commit,
  22. user_signature=user_signature
  23. )
  24. @api.model
  25. def _notify_send(self, body, subject, recipients, **mail_values):
  26. footer_recipients = self.env.context.get(
  27. 'notified_partners', recipients) or recipients
  28. newbody = self.get_additional_footer(footer_recipients)
  29. newbody += body
  30. return super(MailNotification, self).\
  31. _notify_send(newbody, subject, recipients, **mail_values)
  32. @api.model
  33. def get_additional_footer(self, recipients):
  34. recipients_name = [
  35. recipient.name for recipient in recipients
  36. ]
  37. additional_footer = u'<br /><b>%s%s.</b><br />' % \
  38. (_('Also notified: '),
  39. ', '.join(recipients_name))
  40. return additional_footer