[FIX] gamification: various fixes
- generates automatically goals when adding somebody to a challenge - when serialising data, skip lines and challenges with no generated goals - hr_gamification as auto install (when get hr and gamification) - related field challenge_id on gamification.goal is always readonly, add helper - convert missed type->definition conversion in filter name (goal history menu will group by user and definition) - invert challenges and goals menus in setting list (as encourage people to create challenges instead of goals) bzr revid: mat@openerp.com-20140207121637-73a4lhvk7bonibiu
This commit is contained in:
commit
9f4daa71e8
|
@ -387,6 +387,7 @@ class gamification_challenge(osv.Model):
|
|||
end_date = challenge.end_date
|
||||
|
||||
for line in challenge.line_ids:
|
||||
# FIXME: allow to restrict to a subset of users
|
||||
for user in challenge.user_ids:
|
||||
|
||||
goal_obj = self.pool.get('gamification.goal')
|
||||
|
@ -400,8 +401,9 @@ class gamification_challenge(osv.Model):
|
|||
# resume canceled goals
|
||||
domain.append(('state', '=', 'canceled'))
|
||||
canceled_goal_ids = goal_obj.search(cr, uid, domain, context=context)
|
||||
goal_obj.write(cr, uid, canceled_goal_ids, {'state': 'inprogress'}, context=context)
|
||||
goal_obj.update(cr, uid, canceled_goal_ids, context=context)
|
||||
if canceled_goal_ids:
|
||||
goal_obj.write(cr, uid, canceled_goal_ids, {'state': 'inprogress'}, context=context)
|
||||
goal_obj.update(cr, uid, canceled_goal_ids, context=context)
|
||||
|
||||
# skip to next user
|
||||
continue
|
||||
|
@ -516,13 +518,6 @@ class gamification_challenge(osv.Model):
|
|||
domain.append(('user_id', '=', user_id))
|
||||
sorting = goal_obj._order
|
||||
limit = 1
|
||||
# initialise in case search returns no results
|
||||
line_data.update({
|
||||
'id': 0,
|
||||
'current': 0,
|
||||
'completeness': 0,
|
||||
'state': 'draft',
|
||||
})
|
||||
else:
|
||||
line_data.update({
|
||||
'own_goal_id': False,
|
||||
|
@ -559,7 +554,8 @@ class gamification_challenge(osv.Model):
|
|||
'completeness': goal.completeness,
|
||||
'state': goal.state,
|
||||
})
|
||||
res_lines.append(line_data)
|
||||
if goal_ids:
|
||||
res_lines.append(line_data)
|
||||
return res_lines
|
||||
|
||||
##### Reporting #####
|
||||
|
|
|
@ -163,7 +163,8 @@ class gamification_goal(osv.Model):
|
|||
string="Challenge",
|
||||
type='many2one',
|
||||
relation='gamification.challenge',
|
||||
store=True),
|
||||
store=True, readonly=True,
|
||||
help="Challenge that generated the goal, assign challenge to users to generate goals with a value in this field."),
|
||||
'start_date': fields.date('Start Date'),
|
||||
'end_date': fields.date('End Date'), # no start and end = always active
|
||||
'target_goal': fields.float('To Reach',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<group string="Reference">
|
||||
<field name="definition_id" on_change="on_change_definition_id(definition_id)" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="user_id" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="challenge_id" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="challenge_id" />
|
||||
</group>
|
||||
<group string="Schedule">
|
||||
<field name="start_date" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
|
@ -280,8 +280,8 @@
|
|||
|
||||
<!-- menus in settings - technical feature required -->
|
||||
<menuitem id="gamification_menu" name="Gamification Tools" parent="base.menu_administration" groups="base.group_no_one" />
|
||||
<menuitem id="gamification_goal_menu" parent="gamification_menu" action="goal_list_action" sequence="0"/>
|
||||
<menuitem id="gamification_challenge_menu" parent="gamification_menu" action="challenge_list_action" sequence="10"/>
|
||||
<menuitem id="gamification_challenge_menu" parent="gamification_menu" action="challenge_list_action" sequence="0"/>
|
||||
<menuitem id="gamification_goal_menu" parent="gamification_menu" action="goal_list_action" sequence="10"/>
|
||||
<menuitem id="gamification_definition_menu" parent="gamification_menu" action="goal_definition_list_action" sequence="20"/>
|
||||
<menuitem id="gamification_badge_menu" parent="gamification_menu" action="badge_list_action" sequence="30"/>
|
||||
|
||||
|
|
|
@ -37,4 +37,5 @@ Badge received are displayed on the user profile.
|
|||
'views/gamification.xml',
|
||||
],
|
||||
'js': ['static/src/js/gamification.js'],
|
||||
'auto_install': True,
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="name">Goals History</field>
|
||||
<field name="view_mode">tree,kanban</field>
|
||||
<field name="context">{'search_default_group_by_user': True, 'search_default_group_by_type': True}</field>
|
||||
<field name="context">{'search_default_group_by_user': True, 'search_default_group_by_definition': True}</field>
|
||||
<field name="domain">[('challenge_id.category', '=', 'hr')]</field>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
|
|
Loading…
Reference in New Issue