[FIX] gamification: correct report sending

bzr revid: mat@openerp.com-20130621082428-5nxalipljwsgbi2j
This commit is contained in:
Martin Trigaux
2013-06-21 10:24:28 +02:00
parent ad78a1b6aa
commit 027fb2bb23
4 changed files with 11 additions and 18 deletions
+3 -4
View File
@@ -325,16 +325,15 @@ class gamification_goal(osv.Model):
for goal in self.browse(cr, uid, ids, context=context):
if goal.state != "draft" and ('type_id' in vals or 'user_id' in vals):
# avoid drag&drop in kanban view
raise osv.except_osv(_('Error!'), _('Can not modify a started goal'))
raise osv.except_osv(_('Error!'), _('Can not modify the configuration of a started goal'))
if 'current' in vals:
if vals.get('current'):
if 'no_remind_goal' in context:
# new goals should not be reported
continue
if goal.plan_id and goal.plan_id.report_message_frequency == 'onchange':
plan_obj = self.pool.get('gamification.goal.plan')
plan_obj.report_progress(cr, SUPERUSER_ID, goal.plan_id, users=[goal.user_id], context=context)
self.pool.get('gamification.goal.plan').report_progress(cr, SUPERUSER_ID, goal.plan_id, users=[goal.user_id], context=context)
return result
def get_action(self, cr, uid, goal_id, context=None):
+1 -1
View File
@@ -161,7 +161,7 @@
<th>Current</th>
<th>Completeness</th>
</tr>
% for goal in ${ctx["goals"]}:
% for goal in ctx["goals"]:
<tr
% if goal.completeness >= 100:
style="font-weight:bold;"
+6 -12
View File
@@ -505,7 +505,7 @@ class gamification_goal_plan(osv.Model):
if len(related_goal_ids) == 0:
return False
values = {'goals': []}
goals = []
all_done = True
for goal in goal_obj.browse(cr, uid, related_goal_ids, context=context):
if goal.end_date:
@@ -518,13 +518,13 @@ class gamification_goal_plan(osv.Model):
if goal.state == 'inprogress' or goal.state == 'inprogress_update':
all_done = False
values['goals'].append(goal)
goals.append(goal)
if all_done:
# skip plans where all goal are done or failed
return False
else:
return values
return goals
##### Reporting #####
@@ -571,19 +571,13 @@ class gamification_goal_plan(osv.Model):
else:
# generate individual reports
for user in users or plan.user_ids:
values = self.get_indivual_goal_info(cr, uid, user.id, plan, subset_goal_ids, context=context)
if not values:
goals = self.get_indivual_goal_info(cr, uid, user.id, plan, subset_goal_ids, context=context)
if not goals:
continue
# values['object'] = plan
# values['user'] = user
ctx.update({'planlines_boards': planlines_boards})
ctx.update({'goals': goals})
template_id = self.pool['ir.model.data'].get_object(cr, uid, 'gamification', 'email_template_goal_progress_perso', context)
body_html = temp_obj.render_template(cr, user.id, template_id.body_html, 'gamification.goal.plan', plan.id, context=context)
# body_html = template_env.get_template('personal_progress.mako').render(values)
# send message only to users
self.message_post(cr, uid, 0,
body=body_html,
+1 -1
View File
@@ -119,7 +119,7 @@ class res_users_gamification_group(osv.Model):
continue
serialized_goals_info['goals'] = []
for goal in goals_info['goals']:
for goal in goals_info:
serialized_goals_info['goals'].append({
'id': goal.id,
'type_name': goal.type_id.name,