if write_op:
self.write(cr, uid, [challenge.id], {'user_ids': write_op}, context=context)
- if to_remove_ids:
- self.message_unsubscribe_users(cr, uid, [challenge.id], to_remove_ids, context=None)
- if to_add_ids:
- self.message_subscribe_users(cr, uid, [challenge.id], to_add_ids, context=context)
+ if challenge.report_message_frequency != 'never':
+ if to_remove_ids:
+ self.message_unsubscribe_users(cr, uid, [challenge.id], to_remove_ids, context=context)
+ if to_add_ids:
+ self.message_subscribe_users(cr, uid, [challenge.id], to_add_ids, context=context)
+ else:
+ self.message_unsubscribe_users(cr, uid, [challenge.id], old_user_ids, context=context)
return True
_name = 'gamification.goal'
_description = 'Gamification goal instance'
- _inherit = 'mail.thread'
def _get_completion(self, cr, uid, ids, field_name, arg, context=None):
"""Return the percentage of completeness of the goal, between 0 and 100"""
temp_obj = self.pool.get('email.template')
template_id = self.pool['ir.model.data'].get_object(cr, uid, 'gamification', 'email_template_goal_reminder', context)
body_html = temp_obj.render_template(cr, uid, template_id.body_html, 'gamification.goal', goal.id, context=context)
-
- self.message_post(cr, uid, goal.id, body=body_html, partner_ids=[goal.user_id.partner_id.id], context=context, subtype='mail.mt_comment')
+ self.pool['mail.thread'].message_post(cr, uid, 0, body=body_html, partner_ids=[goal.user_id.partner_id.id], context=context, subtype='mail.mt_comment')
return {'to_update': True}
return {}