This question has been flagged

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.

Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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

Avatar
Discard