From e5f05074f8110b3282c558b6108fdc88b41d7522 Mon Sep 17 00:00:00 2001
From: Martin Trigaux <mat@odoo.com>
Date: Thu, 28 Jul 2016 15:46:08 +0200
Subject: [PATCH] [FIX] gamification: remove duplicated manager groups

hr_gamification should be adding hr groups to the security of gamification.
Creating the group base.group_hr_manager in gamification in case hr is not
installed is confusing and redundant with existing manager groups.
---
 .../gamification/security/gamification_security.xml  | 10 ++--------
 addons/gamification/security/ir.model.access.csv     | 12 ++++++------
 .../security/gamification_security.xml               |  9 +--------
 3 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/addons/gamification/security/gamification_security.xml b/addons/gamification/security/gamification_security.xml
index a9e71a57c205..785d533ae4bf 100644
--- a/addons/gamification/security/gamification_security.xml
+++ b/addons/gamification/security/gamification_security.xml
@@ -1,11 +1,5 @@
 <odoo>
     <data noupdate="1">
-        <record id="base.group_hr_manager" model="res.groups">
-            <field name="name">Manager</field>
-            <field name="category_id" ref="base.module_category_human_resources"/>
-            <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
-            <field name="users" eval="[(4, ref('base.user_root'))]"/>
-        </record>
 
         <record id="goal_user_visibility" model="ir.rule">
             <field name="name">User can only see his/her goals or goal from the same challenge in board visibility</field>
@@ -24,9 +18,9 @@
         </record>
 
         <record id="goal_gamification_manager_visibility" model="ir.rule">
-            <field name="name">Gamification Manager can see any goal</field>
+            <field name="name">Manager can see any goal</field>
             <field name="model_id" ref="model_gamification_goal"/>
-            <field name="groups" eval="[(4, ref('base.group_hr_manager'))]"/>
+            <field name="groups" eval="[(4, ref('base.group_erp_manager'))]"/>
             <field name="perm_read" eval="True"/>
             <field name="perm_write" eval="True"/>
             <field name="perm_create" eval="False"/>
diff --git a/addons/gamification/security/ir.model.access.csv b/addons/gamification/security/ir.model.access.csv
index 06d65469a5a8..5bfd05af9ccb 100644
--- a/addons/gamification/security/ir.model.access.csv
+++ b/addons/gamification/security/ir.model.access.csv
@@ -1,19 +1,19 @@
 id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
 
 goal_employee,"Goal Employee",model_gamification_goal,base.group_user,1,1,0,0
-goal_manager,"Goal Manager",model_gamification_goal,base.group_hr_manager,1,1,1,1
+goal_manager,"Goal Manager",model_gamification_goal,base.group_erp_manager,1,1,1,1
 
 goal_definition_employee,"Goal Definition Employee",model_gamification_goal_definition,base.group_user,1,0,0,0
-goal_definition_manager,"Goal Definition Manager",model_gamification_goal_definition,base.group_hr_manager,1,1,1,1
+goal_definition_manager,"Goal Definition Manager",model_gamification_goal_definition,base.group_erp_manager,1,1,1,1
 
 challenge_employee,"Goal Challenge Employee",model_gamification_challenge,base.group_user,1,0,0,0
-challenge_manager,"Goal Challenge Manager",model_gamification_challenge,base.group_hr_manager,1,1,1,1
+challenge_manager,"Goal Challenge Manager",model_gamification_challenge,base.group_erp_manager,1,1,1,1
 
 challenge_line_employee,"Challenge Line Employee",model_gamification_challenge_line,base.group_user,1,0,0,0
-challenge_line_manager,"Challenge Line Manager",model_gamification_challenge_line,base.group_hr_manager,1,1,1,1
+challenge_line_manager,"Challenge Line Manager",model_gamification_challenge_line,base.group_erp_manager,1,1,1,1
 
 badge_employee,"Badge Employee",model_gamification_badge,base.group_user,1,0,0,0
-badge_manager,"Badge Manager",model_gamification_badge,base.group_hr_manager,1,1,1,1
+badge_manager,"Badge Manager",model_gamification_badge,base.group_erp_manager,1,1,1,1
 
 badge_user_employee,"Badge-user Employee",model_gamification_badge_user,base.group_user,1,1,1,0
-badge_user_manager,"Badge-user Manager",model_gamification_badge_user,base.group_hr_manager,1,1,1,1
+badge_user_manager,"Badge-user Manager",model_gamification_badge_user,base.group_erp_manager,1,1,1,1
diff --git a/addons/hr_gamification/security/gamification_security.xml b/addons/hr_gamification/security/gamification_security.xml
index 9213028c550c..86671336c63b 100644
--- a/addons/hr_gamification/security/gamification_security.xml
+++ b/addons/hr_gamification/security/gamification_security.xml
@@ -2,15 +2,8 @@
 <odoo>
     <data noupdate="1">
 
-        <record id="goal_officer_visibility" model="ir.rule">
-            <field name="name">HR Officer can see any goal</field>
-            <field name="model_id" ref="gamification.model_gamification_goal"/>
+        <record id="gamification.goal_gamification_manager_visibility" model="ir.rule">
             <field name="groups" eval="[(4, ref('base.group_hr_user'))]"/>
-            <field name="perm_read" eval="True"/>
-            <field name="perm_write" eval="True"/>
-            <field name="perm_create" eval="False"/>
-            <field name="perm_unlink" eval="False"/>
-            <field name="domain_force">[(1, '=', 1)]</field>
         </record>
 
     </data>
-- 
GitLab