summaryrefslogtreecommitdiff
path: root/addons/gamification
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-09-11 09:39:33 +0000
committerChristophe Simonis <chs@odoo.com>2019-09-11 09:39:33 +0000
commit51354fadb0a1bf5fa797c2539e703cf97d768691 (patch)
tree223535044b0df6473cd343079167c53c0f3673d0 /addons/gamification
parentda6f24bb4cea8b14eacc3040a06c5e451511240f (diff)
parent50e571acf7c9696954d604de9b4501716fa26646 (diff)
[MERGE] forward port branch saas-12.3 up to 50e571acf7c
closes odoo/odoo#36491 Signed-off-by: Christophe Simonis <chs@odoo.com>
Diffstat (limited to 'addons/gamification')
-rw-r--r--addons/gamification/models/challenge.py6
-rw-r--r--addons/gamification/models/goal.py2
-rw-r--r--addons/gamification/views/challenge.xml6
-rw-r--r--addons/gamification/views/goal.xml7
4 files changed, 12 insertions, 9 deletions
diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py
index 5e2515e797c..519a86d5b2f 100644
--- a/addons/gamification/models/challenge.py
+++ b/addons/gamification/models/challenge.py
@@ -383,9 +383,9 @@ class Challenge(models.Model):
# 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
+ values['current'] = min(line.target_goal - 1, 0)
else:
- values['current'] = line.target_goal + 1
+ values['current'] = max(line.target_goal + 1, 0)
if challenge.remind_update_delay:
values['remind_update_delay'] = challenge.remind_update_delay
@@ -743,7 +743,7 @@ class Challenge(models.Model):
all_reached = False
if goal.definition_condition == 'higher':
# can be over 100
- total_completeness += 100.0 * goal.current / goal.target_goal
+ total_completeness += (100.0 * goal.current / goal.target_goal) if goal.target_goal else 0
elif goal.state == 'reached':
# for lower goals, can not get percentage so 0 or 100
total_completeness += 100
diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py
index c5a280f13f2..736ed2da71b 100644
--- a/addons/gamification/models/goal.py
+++ b/addons/gamification/models/goal.py
@@ -196,7 +196,7 @@ class Goal(models.Model):
if goal.current >= goal.target_goal:
goal.completeness = 100.0
else:
- goal.completeness = round(100.0 * goal.current / goal.target_goal, 2)
+ goal.completeness = round(100.0 * goal.current / goal.target_goal, 2) if goal.target_goal else 0
elif goal.current < goal.target_goal:
# a goal 'lower than' has only two values possible: 0 or 100%
goal.completeness = 100.0
diff --git a/addons/gamification/views/challenge.xml b/addons/gamification/views/challenge.xml
index a5f9f4fe2ee..7621bcbb6ad 100644
--- a/addons/gamification/views/challenge.xml
+++ b/addons/gamification/views/challenge.xml
@@ -15,7 +15,7 @@
<record id="goals_from_challenge_act" model="ir.actions.act_window">
<field name="res_model">gamification.goal</field>
<field name="name">Related Goals</field>
- <field name="view_mode">kanban,tree</field>
+ <field name="view_mode">kanban,tree,form</field>
<field name="context">{'search_default_group_by_definition': True, 'search_default_inprogress': True, 'search_default_challenge_id': active_id, 'default_challenge_id': active_id}</field>
<field name="help" type="html">
<p class="o_view_nocontent_empty_folder">
@@ -61,7 +61,7 @@
<label for="user_domain" class="oe_edit_only" string="Assign Challenge To"/>
<div>
<field name="user_domain" widget="domain" options="{'model': 'res.users'}" />
- <field name="user_ids" groups="base.group_no_one" widget="many2many_tags" readonly="True" />
+ <field name="user_ids" widget="many2many_tags" />
</div>
</div>
@@ -171,7 +171,7 @@
<record id="challenge_list_action" model="ir.actions.act_window">
<field name="name">Challenges</field>
<field name="res_model">gamification.challenge</field>
- <field name="view_mode">kanban,tree,form</field>
+ <field name="view_mode">kanban,tree</field>
<field name="context">{'search_default_inprogress':True, 'default_inprogress':True}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
diff --git a/addons/gamification/views/goal.xml b/addons/gamification/views/goal.xml
index 9af36db1948..cd17738869d 100644
--- a/addons/gamification/views/goal.xml
+++ b/addons/gamification/views/goal.xml
@@ -135,6 +135,7 @@
<field name="completeness"/>
<field name="state"/>
<field name="target_goal"/>
+ <field name="definition_description"/>
<field name="definition_condition"/>
<field name="definition_suffix"/>
<field name="definition_display"/>
@@ -143,10 +144,12 @@
<field name="last_update"/>
<templates>
<t t-name="kanban-tooltip">
- <field name="definition_description"/>
+ <ul class="oe_kanban_tooltip">
+ <li><t t-esc="record.definition_description.value" /></li>
+ </ul>
</t>
<t t-name="kanban-box">
- <div t-attf-class="oe_kanban_card o_kanban_gamification #{record.end_date.raw_value &lt; record.last_update.raw_value &amp; record.state.raw_value == 'failed' ? 'oe_kanban_color_2' : ''} #{record.end_date.raw_value &lt; record.last_update.raw_value &amp; record.state.raw_value == 'reached' ? 'oe_kanban_color_5' : ''}">
+ <div t-attf-class="oe_kanban_card oe_kanban_global_click o_kanban_gamification #{record.end_date.raw_value &lt; record.last_update.raw_value &amp; record.state.raw_value == 'failed' ? 'oe_kanban_color_2' : ''} #{record.end_date.raw_value &lt; record.last_update.raw_value &amp; record.state.raw_value == 'reached' ? 'oe_kanban_color_5' : ''}">
<div class="o_kanban_content">
<p><strong><h4 class="oe_goal_name text-center" tooltip="kanban-tooltip"><field name="definition_id" /></h4></strong></p>
<div class="float-left">