"I want to limit the information from certain contacts to some users. The information from this contacts it's confidential and only certain users should have access to it."
This solution works without customizations or development, it is a standard solution.
To limit the access of certain users to the contacts we need 3 configurations:
(With developer mode active)
- Contact tag for restricted contacts.
- Group to define the users for this restriction.
- Record rule with the restriction.
Steps to follow...
1 - Contact tag for restricted users
This tag will help us identify our contact easily and maintain proper Odoo functionalities.
1.- At the contacts application, create a tag (category_id), with the name "Restricted Contact" (the name can be different for every client's need).
2.- Add it to the contacts you want to restrict, as it follows.
2 - Create a filter to exclude the contacts from the shown information
At the contacts app, create a filter which allows us to hide the contacts that our users are not allowed to see.
Apply the rule as shown, and important copy the rule from the code editor, we'll be using it for the further steps.
3 - Create a group to define the users for this restriction
At the settings in the Users and Companies menu, into the groups model. Create a new group, in this group will be all the users that the restriction applies.
Under the Users tab, add the users that will be restricted with this configuration.
4 - Create the rule under "Record Rules" Tab
1.- At the Record rules tab, add a new line, and on the Pop-Up window create a new record with the "New" button.
2.- For the Rule configuration, we need to select model: contact and paste the previous copied rule on the Rule definition (Domain Filter) field, and save the configuration.
5 - Test
Log into the User's account, that we previously added to the rule, open the Contacts module and review.
The contacts with the created tag, should not be shown.
Additional notes:
- For the administrators you don’t need to do anything, as this rule only applies to the users specified in the group.
- This rule applies to specific contacts, it does not affect partner or child contacts, is necessary to assign each contact to restrict.
- When creating new users The admin won't have any problems, as this only applies to the users at the Group defined, just add the tag to the contact related once the user is created.
-The contacts without tag still will be shown for the user.
-Important: This configuration will also hide the contact from all other modules (creating a SO, PO...etc) the user won't be able to select it in any other apps.