diff options
| author | Martin Trigaux <mat@openerp.com> | 2014-04-16 17:10:26 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@openerp.com> | 2014-04-16 17:10:26 +0200 |
| commit | d79cbd3fb88e494ba0827f8a60fc41bdfadd3369 (patch) | |
| tree | 32db5b1efc272733f7a02faedd67a88e924dd5cb /addons/gamification/models/res_users.py | |
| parent | fafeaff7db6ddd2a29ba0346b519612c43286e52 (diff) | |
[FIX] gamification: convert autojoin_group_id to a domain representing the list of users
bzr revid: mat@openerp.com-20140416151026-lmvyo8k0wo4hw9gn
Diffstat (limited to 'addons/gamification/models/res_users.py')
| -rw-r--r-- | addons/gamification/models/res_users.py | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/addons/gamification/models/res_users.py b/addons/gamification/models/res_users.py index faca484dfb3..330311ba05e 100644 --- a/addons/gamification/models/res_users.py +++ b/addons/gamification/models/res_users.py @@ -31,36 +31,6 @@ class res_users_gamification_group(osv.Model): _name = 'res.users' _inherit = ['res.users'] - def write(self, cr, uid, ids, vals, context=None): - """Overwrite to autosubscribe users if added to a group marked as autojoin, user will be added to challenge""" - write_res = super(res_users_gamification_group, self).write(cr, uid, ids, vals, context=context) - if vals.get('groups_id'): - # form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]} - user_group_ids = [command[1] for command in vals['groups_id'] if command[0] == 4] - user_group_ids += [id for command in vals['groups_id'] if command[0] == 6 for id in command[2]] - - challenge_obj = self.pool.get('gamification.challenge') - challenge_ids = challenge_obj.search(cr, SUPERUSER_ID, [('autojoin_group_id', 'in', user_group_ids)], context=context) - if challenge_ids: - challenge_obj.write(cr, SUPERUSER_ID, challenge_ids, {'user_ids': [(4, user_id) for user_id in ids]}, context=context) - challenge_obj.generate_goals_from_challenge(cr, SUPERUSER_ID, challenge_ids, context=context) - return write_res - - def create(self, cr, uid, vals, context=None): - """Overwrite to autosubscribe users if added to a group marked as autojoin, user will be added to challenge""" - write_res = super(res_users_gamification_group, self).create(cr, uid, vals, context=context) - if vals.get('groups_id'): - # form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]} - user_group_ids = [command[1] for command in vals['groups_id'] if command[0] == 4] - user_group_ids += [id for command in vals['groups_id'] if command[0] == 6 for id in command[2]] - - challenge_obj = self.pool.get('gamification.challenge') - challenge_ids = challenge_obj.search(cr, SUPERUSER_ID, [('autojoin_group_id', 'in', user_group_ids)], context=context) - if challenge_ids: - challenge_obj.write(cr, SUPERUSER_ID, challenge_ids, {'user_ids': [(4, write_res)]}, context=context) - challenge_obj.generate_goals_from_challenge(cr, SUPERUSER_ID, challenge_ids, context=context) - return write_res - def get_serialised_gamification_summary(self, cr, uid, excluded_categories=None, context=None): return self._serialised_goals_summary(cr, uid, user_id=uid, excluded_categories=excluded_categories, context=context) @@ -112,28 +82,3 @@ class res_users_gamification_group(osv.Model): } challenge_info.append(values) return challenge_info - - -class res_groups_gamification_group(osv.Model): - """ Update of res.groups class - - if adding users from a group, check gamification.challenge linked to - this group, and the user. This is done by overriding the write method. - """ - _name = 'res.groups' - _inherit = 'res.groups' - - # No need to overwrite create as very unlikely to be the value in the autojoin_group_id field - def write(self, cr, uid, ids, vals, context=None): - """Overwrite to autosubscribe users if add users to a group marked as autojoin, these will be added to the challenge""" - write_res = super(res_groups_gamification_group, self).write(cr, uid, ids, vals, context=context) - if vals.get('users'): - # form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]} - user_ids = [command[1] for command in vals['users'] if command[0] == 4] - user_ids += [id for command in vals['users'] if command[0] == 6 for id in command[2]] - - challenge_obj = self.pool.get('gamification.challenge') - challenge_ids = challenge_obj.search(cr, SUPERUSER_ID, [('autojoin_group_id', 'in', ids)], context=context) - if challenge_ids: - challenge_obj.write(cr, SUPERUSER_ID, challenge_ids, {'user_ids': [(4, user_id) for user_id in user_ids]}, context=context) - challenge_obj.generate_goals_from_challenge(cr, SUPERUSER_ID, challenge_ids, context=context) - return write_res |
