[FIX] gamification: avoid challenge to be initialised at the target limit (e.g. set...
authorMartin Trigaux <mat@openerp.com>
Fri, 9 May 2014 13:18:39 +0000 (15:18 +0200)
committerMartin Trigaux <mat@openerp.com>
Fri, 9 May 2014 13:18:39 +0000 (15:18 +0200)
bzr revid: mat@openerp.com-20140509131839-lm5zt696sif1krvx

addons/gamification/data/goal_base.xml
addons/gamification/models/challenge.py

index 1c18a5a..93ca8af 100644 (file)
             <field name="computation_mode">count</field>
             <field name="display_mode">boolean</field>
             <field name="model_id" eval="ref('base.model_res_company')" />
-            <field name="domain">[('user_ids', 'in', [user.id]), ('name', '=', 'Your Company')]</field>
+            <field name="domain">[('user_ids', 'in', [user.id]), ('name', '=', 'YourCompany')]</field>
             <field name="condition">lower</field>
             <field name="action_id" eval="ref('base.action_res_company_form')" />
             <field name="res_id_field">user.company_id.id</field>
index b532232..8ed3890 100644 (file)
@@ -422,6 +422,12 @@ class gamification_challenge(osv.Model):
                     if end_date:
                         values['end_date'] = end_date
 
+                    # the goal is initialised over the limit to make sure we will compute it at least once
+                    if line.condition == 'higher':
+                        values['current'] = line.target_goal - 1
+                    else:
+                        values['current'] = line.target_goal + 1
+
                     if challenge.remind_update_delay:
                         values['remind_update_delay'] = challenge.remind_update_delay