Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lip 24
1553
0
lip 24
3
2
maj 25
1036
1
lis 23
1901
2
gru 19
9905