Solving Odoo Multicompany Access Rights Issue on Contact Model

Managing multiple companies in Odoo can be a complex task, especially when it comes to setting access rights and permissions. A common problem many Odoo users face is that the default permissions on the contact model (res.partner) do not allow access to users managed companies, even if they have the relevant companies selected in their company_ids settings. This blog post will guide you through a solution to this issue by modifying the default permission rules.

The Problem

By default, Odoo sets the following domain on the contact model to control access rights:

['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]

This domain restricts access to contacts in the following ways:

  1. Contacts belonging to the user’s company or its child companies.
  2. Contacts with no company specified (shared contacts).

However, this does not consider other companies that the user might have access to via the company_ids field in their user settings. As a result, users cannot see contacts from these companies, which is not the desired behavior in a multicompany setup.

The Solution

To solve this problem, we need to extend the default domain to include companies listed in the user’s company_ids. The revised domain is as follows:

['|','|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False),('company_id', 'in', [company.id for company in user.company_ids])]

This updated domain includes an additional check that allows access to contacts from any of the companies specified in the user’s company_ids.

Conclusion

By modifying the default permission rules, you can ensure that users have access to contacts from all companies they are associated with in a multicompany setup. This small adjustment can greatly enhance the usability and efficiency of Odoo in a multicompany environment.

By following the steps outlined above, you can solve the access rights issue and ensure a smoother experience for users managing contacts across multiple companies. If you have any questions or run into any issues, feel free to leave a comment below!

Thanks to this post for drive me to the right direction!

https://www.odoo.com/it_IT/forum/assistenza-1/multicompany-access-rights-why-is-the-field-res-user-company-ids-not-used-43842