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.

45 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. body += self.get_additional_footer(footer_recipients)
  29. return super(MailNotification, self).\
  30. _notify_send(body, subject, recipients, **mail_values)
  31. @api.model
  32. def get_additional_footer(self, recipients):
  33. recipients_name = [
  34. recipient.name for recipient in recipients
  35. ]
  36. additional_footer = u'<br /><small>%s%s.</small><br />' % \
  37. (_('Also notified: '),
  38. ', '.join(recipients_name))
  39. return additional_footer