From 027fb2bb2320f933f612f1b7bf0502746e14a868 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 21 Jun 2013 10:24:28 +0200 Subject: [PATCH] [FIX] gamification: correct report sending bzr revid: mat@openerp.com-20130621082428-5nxalipljwsgbi2j --- addons/gamification/goal.py | 7 +++---- addons/gamification/goal_base_data.xml | 2 +- addons/gamification/plan.py | 18 ++++++------------ addons/gamification/res_users.py | 2 +- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 32bcc3e513b..e61858c2788 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -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): diff --git a/addons/gamification/goal_base_data.xml b/addons/gamification/goal_base_data.xml index b0e21b977cb..a97360ef9ff 100644 --- a/addons/gamification/goal_base_data.xml +++ b/addons/gamification/goal_base_data.xml @@ -161,7 +161,7 @@ Current Completeness - % for goal in ${ctx["goals"]}: + % for goal in ctx["goals"]: = 100: style="font-weight:bold;" diff --git a/addons/gamification/plan.py b/addons/gamification/plan.py index 4375474fd05..3a823e6ce21 100644 --- a/addons/gamification/plan.py +++ b/addons/gamification/plan.py @@ -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, diff --git a/addons/gamification/res_users.py b/addons/gamification/res_users.py index 3ccdf592881..28ec11eab87 100644 --- a/addons/gamification/res_users.py +++ b/addons/gamification/res_users.py @@ -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,