Skip to Content
Menu
This question has been flagged
1 Reply
1756 Views

We use Odoo 12.0 CE and our employees should self-fill their timesheets. Therefore we have to set their access rights to "User" (German: "Personalsachbearbeiter" which BTW translates to "HR Administrator"). The consequence is that these users can not only fill their own timesheet but can also access other employees timesheets and Employee information. Instead we need an access groups such as "own timesheets only" but it doesn't exist. But perhaps I didn't grasp Odoo's concept how employees should self-fill their time (maybe by exclusively using tasks?). Any advice?

Avatar
Discard
Best Answer

Hi,

By following these steps you can create a new rule for the users.

1. Hope you have a module category for the module to add the security groups.
eg: 

<record id="module_module_name" model="ir.module.category">
        <field name="name">Module Name</field>
        <field name="description">Access for Module Name</field>
        <field name="sequence">50</field>
 </record>

2. The next step is to create the security group. You can refer to the code below.

<record id="module_name_own_documents" model="res.groups">


        <field name="name">Own Timesheets Only</field>


        <field name="category_id" ref="your category id"/>


</record>

3. Next, add access rights for the newly created group in your security file.

eg: access_model_name_own_documents,access.model.name.own.documents,model_model_name,module_name_own_documents,1,1,1,0

4. Add a field in your model for the user of the corresponding employee.

user_id = fields.Many2one('res.users', string='User',related='employee_id.user_id',help='The user of the employee')

5. And last, create the rule for viewing and creating own documents.

<record id="model_name_rule_user" model="ir.rule">
    <field name="name">Model Name: Own Records</field>
    <field name="model_id" ref="model_model_name"/>
    <field name="domain_force">[('user_id', '=', user.id)]</field>
    <field name="groups" eval="[(4, ref('module_name.user_group'))]"/>
</record>


Regards

Avatar
Discard
Related Posts Replies Views Activity
5
Jun 17
4551
0
Feb 23
944
0
Mar 25
351
0
Dec 23
726
0
Nov 23
43