diff options
Diffstat (limited to 'addons/gamification/models/res_users.py')
| -rw-r--r-- | addons/gamification/models/res_users.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/addons/gamification/models/res_users.py b/addons/gamification/models/res_users.py index 408ddddf082..d25d725a4ac 100644 --- a/addons/gamification/models/res_users.py +++ b/addons/gamification/models/res_users.py @@ -42,6 +42,7 @@ class res_users_gamification_group(osv.Model): challenge_ids = challenge_obj.search(cr, uid, [('autojoin_group_id', 'in', user_group_ids)], context=context) if challenge_ids: challenge_obj.write(cr, uid, challenge_ids, {'user_ids': [(4, user_id) for user_id in ids]}, context=context) + challenge_obj.generate_goals_from_challenge(cr, uid, challenge_ids, context=context) return write_res def create(self, cr, uid, vals, context=None): @@ -56,6 +57,7 @@ class res_users_gamification_group(osv.Model): challenge_ids = challenge_obj.search(cr, uid, [('autojoin_group_id', 'in', user_group_ids)], context=context) if challenge_ids: challenge_obj.write(cr, uid, challenge_ids, {'user_ids': [(4, write_res)]}, context=context) + challenge_obj.generate_goals_from_challenge(cr, uid, challenge_ids, context=context) return write_res # def get_goals_todo_info(self, cr, uid, context=None): @@ -83,13 +85,15 @@ class res_users_gamification_group(osv.Model): challenge_ids = challenge_obj.search(cr, uid, [('user_ids', 'in', uid), ('state', '=', 'inprogress')], context=context) for challenge in challenge_obj.browse(cr, uid, challenge_ids, context=context): # serialize goals info to be able to use it in javascript - all_goals_info.append({ - 'id': challenge.id, - 'name': challenge.name, - 'visibility_mode': challenge.visibility_mode, - 'currency': user.company_id.currency_id.id, - 'lines': challenge_obj._get_serialized_challenge_lines(cr, uid, challenge, user_id, restrict_top=MAX_VISIBILITY_RANKING, context=context), - }) + lines = challenge_obj._get_serialized_challenge_lines(cr, uid, challenge, user_id, restrict_top=MAX_VISIBILITY_RANKING, context=context) + if lines: + all_goals_info.append({ + 'id': challenge.id, + 'name': challenge.name, + 'visibility_mode': challenge.visibility_mode, + 'currency': user.company_id.currency_id.id, + 'lines': lines, + }) return all_goals_info @@ -129,4 +133,5 @@ class res_groups_gamification_group(osv.Model): challenge_ids = challenge_obj.search(cr, uid, [('autojoin_group_id', 'in', ids)], context=context) if challenge_ids: challenge_obj.write(cr, uid, challenge_ids, {'user_ids': [(4, user_id) for user_id in user_ids]}, context=context) + challenge_obj.generate_goals_from_challenge(cr, uid, challenge_ids, context=context) return write_res |
