Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2566 Widoki

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?

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
5
cze 17
5420
0
lut 23
1661
0
mar 25
1027
0
gru 23
1642
0
lis 23
43