Draft: FIX remove user partners from multi_company
Odoo shares res.partner
between all the companies when there are users related to them to be able to show that information when there is interaction in a shared record like in a mail.activity
or last user interaction...
Record rule for partner computes partner_share
and set it True
if user is odoo-bot or has a user related to them and it have internal user group
.
<record model="ir.rule" id="res_partner_rule"> <field name="name">res.partner company</field> <field name="model_id" ref="base.model_res_partner"/> <!-- We exclude partners that have internal users ('partner_share' field) from the multi-company rule because it might interfere with the user's company rule and make some users unselectable in relational fields. This means that partners of internal users are always visible, not matter the company setting. --> <field name="domain_force">['|', '|', ('partner_share', '=', False), ('company_id', 'in', company_ids), ('company_id', '=', False)]/field> </record>
Fix 1
Use partner_multi_company
oca module. https://github.com/OCA/multi-company/tree/14.0/partner_multi_company
This module allows relating multiple companies to partners and modifies.
Also modifies the ir.rule
of partner to ONLY filter by company_ids
, this cause an error when accessing a record that has information related to a user. It does not block access to the record, only to the field related to user.
If we implement this solution we need to be update partner to be the same as the company_ids from the user related as this is not done automatically and can cause these errors.
This fix will work if we can assure that there will be no shared records between a company that relate to a user that is not from that company. But this can happen in a lot of cases like if we remove access to CE will still have old records where this user interacted with them.
Fix 2
Use a domain for the action window of res.partner
. We can filter when entering the views to only show the correct partners, users will still be able to see the partner users via URL but when odoo will be able to show correctly and without error in the shared records.
Fix 3
Apply the 2 solutions. There is no documentation on why the ir.rule
of res.partner
was added that way in partner_multi_company
module but if we change it to contemplate also partners users we can solve the problems of permissions and if we apply the domain it only will show when needed by odoo.