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.2 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 import osv
  8. from openerp.osv import fields
  9. class mail_message(osv.osv):
  10. '''Extend mail_message with action_needed flag'''
  11. _inherit = 'mail.message'
  12. def set_action_needed_off(self, cr, user, ids, args):
  13. self.write(cr, user, ids, {'action_needed': False})
  14. return True
  15. def set_action_needed_on(self, cr, user, ids, args):
  16. self.write(cr, user, ids, {'action_needed': True, })
  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)
  23. and (vals['state'] == 'received')):
  24. vals['action_needed'] = True
  25. mm_id = super(mail_message, self).create(cr, user, vals, 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. ),
  32. }