Ir al contenido
Menú
Se marcó esta pregunta

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
Descartar
Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
jul 24
1412
0
jul 24
3
2
may 25
823
1
nov 23
1762
2
dic 19
9787