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

Hi there,

For few days now I am experiencing issues with setting up the Record Rules correct way. 


So the plan is that each customer profile in CRM should be only visible to the user who is assigned as Sales Person. Otherwise, any other people should not see it (apart from Admins).


What's the best practical way to get this sorted via Record Rules? 


Ảnh đại diện
Huỷ bỏ
Tác giả

After checking logs, there is an error:

odoo.addons.base.models.ir_rule: Access Denied by record rules for operation: read on record ids: [3, 15], uid: 9, model: res.partner

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

I did that however, now when user try to access record in CRM that have any logs from other users the system is giving an error: 

Due to security restrictions, you are not allowed to access 'Contact' (res.partner) records. Records: Test Record, Administrator (id=3) User: Test Partner Account (id=9)


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

Hi,

You can add the domain_force like

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

Example:

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


        <field name="name">Salesperson Access Only</field>


        <field name="model_id" ref="base.model_res_partner"/>


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


        <field name="groups"


               eval="[(4, ref('sales_team.group_sale_manager'))]"/>


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


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


    </record>   


Regards

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