Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

A user have access to all his records, while he can only read other people records

形象
odoo
形象
丢弃
1 答案
0
形象
odoo
最佳答案

Hi,

I tried your code and no records were visible in the tree view. Hope you have the same issue.
Now, you can achieve your requirement: read & create to all records and all access to self records, by adding the group in the rule. When I added the access right for the model 'lab.calendar' I have given all permissions to the Internal Users Group(base.group_user) in the CSV file. So, I have added the same group in the rule. If you have used any custom group to set access rights for this model, use that group in the rule replacing the 'base.group_user'.

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


    <field name="name">Change his own info</field>


    <field name="model_id" ref="model_lab_calendar"/>


    <field name="domain_force">[('current_user.id', '=', user.id)]</field>


    <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="True"/>


    <field name="perm_unlink" eval="True"/>


</record>



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


    <field name="name">Read all</field>


    <field name="model_id" ref="model_lab_calendar"/>


    <field name="domain_force">[('current_user.id', '!=', user.id)]</field>


    <field name="groups" eval="[(4,ref('base.group_user'))]"/>


    <field name="perm_read" eval="True"/>


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


    <field name="perm_create" eval="True"/>


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


</record>


Regards

1 备注
形象
丢弃
形象
odoo
-

Thank you for your answer, I'm a bit new to security rules in Odoo, I figured it out later, Thank you