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.3 KiB

  1. # -*- coding: UTF-8 -*-
  2. '''
  3. Created on 16 apr. 2013
  4. @author: Therp BV
  5. http://www.therp.nl
  6. '''
  7. from openerp.osv.orm import Model
  8. from openerp.osv import fields
  9. class mail_message(Model):
  10. '''Extend mail_message with action_needed flag'''
  11. _inherit = 'mail.message'
  12. def set_action_needed_off(self, cr, user, ids, context=None):
  13. self.write(cr, user, ids, {'action_needed': False}, context=context)
  14. return True
  15. def set_action_needed_on(self, cr, user, ids, context=None):
  16. self.write(cr, user, ids, {'action_needed': True}, context=context)
  17. return True
  18. def create(self, cr, user, vals, context=None):
  19. # Set newly received messages as needing action, unless an
  20. # explicit value for action_needed has been passed.
  21. if ((not 'action_needed' in vals)
  22. and ('state' in vals) and (vals['state'] == 'received')):
  23. vals['action_needed'] = True
  24. mm_id = super(mail_message, self).create(
  25. cr, user, vals, context=context)
  26. return mm_id
  27. _columns = {
  28. 'action_needed': fields.boolean('Action needed',
  29. help='Action needed is True whenever a new mail is received, or'
  30. ' when a user flags a message as needing attention.'),
  31. }