Skip to content

Commit

Permalink
Merge c439a86 into 8fe1e06
Browse files Browse the repository at this point in the history
  • Loading branch information
mikevhe18 committed Nov 26, 2018
2 parents 8fe1e06 + c439a86 commit 61f0740
Show file tree
Hide file tree
Showing 10 changed files with 1,064 additions and 82 deletions.
2 changes: 1 addition & 1 deletion hr_timesheet_security/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "HR Timesheet - Security",
"version": "8.0.1.0.0",
"version": "8.0.2.0.0",
"category": "Human Resource",
"website": "https://opensynergy-indonesia.com",
"author": "OpenSynergy Indonesia",
Expand Down
2 changes: 1 addition & 1 deletion hr_timesheet_security/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
hr_timesheet_sheet_sheet_employee,hr_timesheet_sheet.sheet - Employee,hr_timesheet_sheet.model_hr_timesheet_sheet_sheet,base.group_user,1,0,0,0
hr_timesheet_sheet_sheet_user,hr_timesheet_sheet.sheet - Timesheet User,hr_timesheet_sheet.model_hr_timesheet_sheet_sheet,group_timesheet_user,1,1,1,1
hr_timesheet_sheet_sheet_user,hr_timesheet_sheet.sheet - Timesheet User,hr_timesheet_sheet.model_hr_timesheet_sheet_sheet,group_timesheet_operation_user,1,1,1,1
8 changes: 4 additions & 4 deletions hr_timesheet_security/security/ir_module_category_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<openerp>
<data>

<record id="module_attendance_timesheet" model="ir.module.category">
<field name="name">Timesheet</field>
<record id="module_hr_timesheet_operation" model="ir.module.category">
<field name="name">Timesheet Operation</field>
</record>

<record id="module_attendance_timesheet_visibility" model="ir.module.category">
<field name="name">Timesheet Visibility</field>
<record id="module_hr_timesheet_viewer" model="ir.module.category">
<field name="name">Timesheet Viewer</field>
</record>

</data>
Expand Down
181 changes: 120 additions & 61 deletions hr_timesheet_security/security/ir_rule_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,130 @@
<!-- Copyright 2018 OpenSynergy Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0) -->
<openerp>
<data noupdate="0">
<data noupdate="1">

<!-- Timesheet -->
<record id="hr_timesheet_sheet.timesheet_comp_rule"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="name"> Timesheet multi-company</field>
<field name="active" eval="0"/>
</record>
<!-- Timesheet -->
<record id="hr_timesheet_sheet.timesheet_comp_rule"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="name"> Timesheet multi-company</field>
<field name="active" eval="0"/>
</record>

<record id="ir_rule_timesheet_user"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.user_id.id','=',user.id),
]</field>
<field name="name">Timesheet Rule for User</field>
<field name="groups" eval="[(6, 0, [ref('base.group_user')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>
<!-- Employee -->
<record id="ir_rule_timesheet_employee"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.user_id.id','=',user.id),
]</field>
<field name="name">Timesheet Rule for Employee</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
<field eval="0" name="perm_unlink"/>
<field eval="0" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="0" name="perm_create"/>
</record>

<record id="ir_rule_timesheet_supervisor"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.parent_id.id','child_of',user.employee_ids[0].id),
]</field>
<field name="name">Timesheet Rule for Manager</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_supervisor')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>
<!-- Operation -->
<record id="ir_rule_timesheet_operation_user"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.user_id.id','=',user.id),
]</field>
<field name="name">Operation: Timesheet Rule for User</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_operation_user')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>

<record id="ir_rule_timesheet_manager"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('department_id.manager_id.id','child_of',user.employee_ids[0].id),
]</field>
<field name="name">Timesheet Rule for Department</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_department')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>
<record id="ir_rule_timesheet_operation_supervisor"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.parent_id.id','child_of',user.employee_ids[0].id),
]</field>
<field name="name">Operation: Timesheet Rule for Manager</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_operation_supervisor')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>

<record id="ir_rule_timesheet_company"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('company_id.id','child_of',user.company_id.id),
]</field>
<field name="name">Timesheet Rule for Company</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_company')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>
<record id="ir_rule_timesheet_operation_department"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.department_id.manager_id.id','child_of',user.employee_ids[0].id),
]</field>
<field name="name">Operation: Timesheet Rule for Department</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_operation_department')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>

</data>
<record id="ir_rule_timesheet_operation_company"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.user_id.company_id.id','child_of',user.company_id.id),
]</field>
<field name="name">Operation: Timesheet Rule for Company</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_operation_company')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>

<!-- Viewer -->
<record id="ir_rule_timesheet_viewer_supervisor"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.parent_id.id','child_of',user.employee_ids[0].id),
]</field>
<field name="name">Viewer: Timesheet Rule for Manager</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_viewer_supervisor')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>

<record id="ir_rule_timesheet_viewer_department"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.department_id.manager_id.id','child_of',user.employee_ids[0].id),
]</field>
<field name="name">Viewer: Timesheet Rule for Department</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_viewer_department')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>

<record id="ir_rule_timesheet_viewer_company"
model="ir.rule">
<field name="model_id" ref="hr_timesheet_sheet.model_hr_timesheet_sheet_sheet"/>
<field name="domain_force">[
('employee_id.user_id.company_id.id','child_of',user.company_id.id),
]</field>
<field name="name">Viewer: Timesheet Rule for Company</field>
<field name="groups" eval="[(6, 0, [ref('group_timesheet_viewer_company')])]"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>

</data>
</openerp>
47 changes: 34 additions & 13 deletions hr_timesheet_security/security/res_groups_data.xml
Original file line number Diff line number Diff line change
@@ -1,32 +1,53 @@
<?xml version="1.0"?>
<!-- Copyright 2018 OpenSynergy Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0) -->
<openerp>
<data>
<data noupdate="1">

<record id="group_timesheet_user" model="res.groups">
<!-- Timesheet Operator -->
<record id="group_timesheet_operation_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="hr_timesheet_security.module_attendance_timesheet"/>
<field name="category_id" ref="hr_timesheet_security.module_hr_timesheet_operation"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>

<record id="group_timesheet_operation_supervisor" model="res.groups">
<field name="name">Supervisor</field>
<field name="category_id" ref="hr_timesheet_security.module_hr_timesheet_operation"/>
<field name="implied_ids" eval="[(4, ref('group_timesheet_operation_user'))]"/>
</record>

<record id="group_timesheet_operation_department" model="res.groups">
<field name="name">Department</field>
<field name="category_id" ref="hr_timesheet_security.module_hr_timesheet_operation"/>
<field name="implied_ids" eval="[(4, ref('group_timesheet_operation_supervisor'))]"/>
</record>

<record id="group_timesheet_operation_company" model="res.groups">
<field name="name">Company</field>
<field name="category_id" ref="hr_timesheet_security.module_hr_timesheet_operation"/>
<field name="implied_ids" eval="[(4, ref('group_timesheet_operation_department'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>

<record id="group_timesheet_supervisor" model="res.groups">
<!-- Timesheet Viewer -->
<record id="group_timesheet_viewer_supervisor" model="res.groups">
<field name="name">Supervisor</field>
<field name="category_id" ref="hr_timesheet_security.module_attendance_timesheet_visibility"/>
<field name="category_id" ref="hr_timesheet_security.module_hr_timesheet_viewer"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>

<record id="group_timesheet_department" model="res.groups">
<record id="group_timesheet_viewer_department" model="res.groups">
<field name="name">Department</field>
<field name="category_id" ref="hr_timesheet_security.module_attendance_timesheet_visibility"/>
<field name="implied_ids" eval="[(4, ref('group_timesheet_supervisor'))]"/>
<field name="category_id" ref="hr_timesheet_security.module_hr_timesheet_viewer"/>
<field name="implied_ids" eval="[(4, ref('group_timesheet_viewer_supervisor'))]"/>
</record>

<record id="group_timesheet_company" model="res.groups">
<record id="group_timesheet_viewer_company" model="res.groups">
<field name="name">Company</field>
<field name="category_id" ref="hr_timesheet_security.module_attendance_timesheet_visibility"/>
<field name="implied_ids" eval="[(4, ref('group_timesheet_department'))]"/>
<field name="category_id" ref="hr_timesheet_security.module_hr_timesheet_viewer"/>
<field name="implied_ids" eval="[(4, ref('group_timesheet_viewer_department'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>


</data>
</openerp>
6 changes: 6 additions & 0 deletions hr_timesheet_security/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_timesheet_operator
from . import test_timesheet_viewer
Loading

0 comments on commit 61f0740

Please sign in to comment.