Skip to Content
Menú
This question has been flagged
1 Respondre
88 Vistes

How to set restriction on contacts so that the user can see only those contacts they created. They should not see even their own user/employee contact created when we create the user. However, the admin can see all the contacts and the user with group "User: All Documents".

I am using Odoo 19.0+e (Enterprise Edition).

I have tried many methods and solution posted on the forum and somehow through the suggested method, by adding the mentioned record rule, I can see the contacts are getting restricted for a user but when I click on any contact from the list, I am getting an error something like:
Uh-oh! Looks like you have stumbled upon some top-secret records.

Sorry, Ravi Singh (id=7) doesn't have 'read' access to: - Contact (res.partner)

If you really, really need access, perhaps you can win over your friendly administrator with a batch of freshly baked cookies.

Further, the Avatar Image is also not getting loaded for the restricted user after I add the record rule.

Please help.

Avatar
Descartar
Autor

I am replying on this rather than commenting, as commenting is currently inactive/disabled (greyed out), so I was left with no other option.

I tried this, and this is not the solution. Let me explain what is happening here:
First, the links you shared are for Odoo On-premise (self-hosted version), and here at Odoo 19.0+e (Online version), I don't have access to the source code. All I can do is make changes via the GUI (Admin Zone > Developer Mode).

I followed all the steps carefully you mentioned, but it is indeed restricting the contacts view for the user. but if that user clicks on any contact in the list, which he is supposed to have access to, it throws the same error, and the avatar image is also not getting loaded.

There is something you might be missing, or the developers of Odoo Enterprise haven't revealed yet. I have also observed that Odoo's business model is to push the customer to partners for active support rather than giving support via the forum.

Are you willing to dig deeper with me to resolve this issue?

Please let me know what other info/screenshot/data you want from me in this regard.

Best Answer

Hi,

To restrict contact visibility in Odoo, create a security group (e.g., "Contacts: Own Contacts Only") and a record rule ("Contacts: See Own Contacts Only") for the res.partner model. Apply the rule to the new group, granting "Read" permission. Use the domain [('create_uid', '=', user.id), ('user_id', '=', False)] to show only contacts created by the user, excluding their own user/employee contact by checking that the user_id field is False.


Apply the security group to the appropriate users. Ensure the "User: All Documents" group isn't affected by this rule. Test thoroughly, considering performance and upgrade compatibility. This setup allows users to see only their created contacts, excluding their own user contact, while admins retain full visibility.

Reference:-

https://www.cybrosys.com/blog/how-to-create-record-rules-in-odoo-18

https://www.odoo.com/documentation/19.0/developer/reference/backend/security.html

https://www.youtube.com/watch?v=VffPH0GJ_IM


Hope it helps

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de nov. 24
1311
3
de des. 24
5676
2
de juny 24
2186
1
de set. 23
2711
1
d’oct. 21
3655