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.

39 lines
1.6 KiB

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