跳至內容
選單
此問題已被標幟

i would like to know how to use record rules to limit some users to view only their own contact in which they are assigned as salesperson.  what would be the domain i write in the record rule? for example:

salesman name is john,  partners i have are customers, vendors,  when john access the contacts, i want to limit his access to partners which john is assigned as salesman.

i wanna do that without affecting  john's manager from accessing all contacts.

頭像
捨棄
最佳答案

Use the following domain in your record rules:

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

user_id: It is a Salesperson in Contact
user.id: ID of a current logged in user

頭像
捨棄
最佳答案

Hi,

You can create a record rule and set domain as    <field name="domain_force">[('user_id', '=', user.id)]</field>  where user_id is the many2one field with co-model res.users and user.id will give the current logged in user.


See a sample:

<record id="rule_slide_channel_officer_cw" model="ir.rule">
<field name="name">Channel: officer: create/write own only</field>
<field name="model_id" ref="model_slide_channel"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('group_website_slides_officer'))]"/>
<field name="perm_unlink" eval="0"/>
<field name="perm_write" eval="1"/>
<field name="perm_read" eval="0"/>
<field name="perm_create" eval="1"/>
</record>


To know more about the record rules in Odoo: Record Rules in Odoo


Thanks

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
7月 24
1379
0
7月 24
3
2
5月 25
781
1
11月 23
1739
2
12月 19
9769