Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
10387 Lượt xem

All I want is that each employee accessing module Employee in odoo just can see their own record, not others' records.

I have a solution where employee can see all records of other employees, but can't edit them - just their own records. I create new record rule in Settings > Technical > Security > Record Rules to do this solution

But this is not what I want :(

Any solution for my problem, please?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hey Lao Thai ,


You can try this in record rule i think it's help you [('user_id','=',user.id)]

Ảnh đại diện
Huỷ bỏ

These is the perfect answer for such a question

Tác giả Câu trả lời hay nhất

Hi Manish Bohra,

I've tried but this just help me with see all employee and edit own record, not record's other. Employee can see all record, it's not true at all. So any suggest more for me, sir?


And hi Ibrahim, 

What about file csv, I 've tried but this give me an error like this

Exception: Module loading Quy_Trinh_Du_An failed: file Quy_Trinh_Du_An\security/ir.model.access.csv could not be processed: No matching record found for external id 'model_hr_employee' in field 'Object'

Missing required value for the field 'Object' (model_id)

Any Idea?


I'm sorry, i don't have enough karma to answer each answer.

Ảnh đại diện
Huỷ bỏ

Hi LaeThai,

what is the name of your model ? i just mentioned model_hr_employee for an example.

in csv file:

access_model_x_id,access_model_x,model_YOUR_MODDEL_Name,base.group_user,1,1,0,0

Câu trả lời hay nhất

Try :

<record id="rule_case_RU_employes" model="ir.rule">

        <field name="name">RU Employes</field>

        <field name="model_id" ref="model_Your_MODEL"/>      // model_hr_employee ?

        <field name="global" eval="False"/>

        <field name="groups" eval="[(4, ref('base.group_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"> [('create_uid', '=', uid)] </field>

    </record>


Ảnh đại diện
Huỷ bỏ

Hello Ibrahim,

[('create_uid', '=', uid)] this domain will not work, because some times manager or admin will create an employee.

managers/admin should create an employee

Câu trả lời hay nhất

Yes, we can do it by record rules

[('user_id','=',user.id)]

Note : By using above record rule user can see only mapped employee details, use this record rule for employee group and manager group have domain [(1,'=',1)]

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 19
2963
0
thg 12 18
3527
1
thg 3 22
13617
1
thg 6 21
6761
2
thg 12 19
3196