Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
4665 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
lug 24
1453
0
lug 24
3
2
mag 25
870
1
nov 23
1803
2
dic 19
9811