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.

40 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2004-2010 OpenERP SA (<http://www.openerp.com>)
  3. # Copyright 2011-2015 Serpent Consulting Services Pvt. Ltd.
  4. # Copyright 2017 Tecnativa - Vicent Cubells
  5. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  6. import base64
  7. from openerp import _, models, fields
  8. class MailThread(models.Model):
  9. _inherit = "mail.thread"
  10. def _track_signature(self, values, field):
  11. """ This method allows to track creation and deletion of signature
  12. field. You must call this method in order to display a message
  13. in the chatter with information of the changes in the signature.
  14. :param values: a dict with the values being written
  15. :param field: name of the field that must be tracked
  16. """
  17. if field in values:
  18. attachments = []
  19. messages = []
  20. if values.get(field):
  21. content = base64.b64decode(values.get(field))
  22. attachments = [('signature', content)]
  23. messages.append(_('Signature has been created.'))
  24. messages.append(
  25. _('Signature date: %s' % fields.Datetime.now()))
  26. else:
  27. messages.append(_('Signature has been deleted.'))
  28. messages.append(_('Deletion date: %s' % fields.Datetime.now()))
  29. msg_body = '<ul>'
  30. for message in messages:
  31. msg_body += '<li>'
  32. msg_body += message
  33. msg_body += '</li>'
  34. msg_body += '</ul>'
  35. self.message_post(body=msg_body, attachments=attachments)