In a multi-company setup of OpenERP there is a new field available for the users "res.user.company_ids" but it seems that this field will not be taken into account on any of the access Rules:
Acces Rules for res.partner
['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]
Or Access Rule for res.companies
[('id','child_of',[user.company_id.id])]
I do understand that OpenERP is by default sharing it's documents between Parents and Children and not between brother and sister wich is abvious if you look at
('company_id.child_ids','child_of',[user.company_id.id]) and ('company_id','child_of',[user.company_id.id])
BUT I really don't understand for what the field res.user.company_ids is for? Could somebody shed some light on this?
I was expecting that if all of my companies are in an hierarchy like this:
Company A > Company B > Company C
and a user belongs to "Company B and has set the field "res.user.company_ids" to "Company B" and "Company A" he could see all the partners (contacts) from "Company A" and "Company B" but NOT from "Company C". But in reality he will be able to see all the contacts from all the companies including "Company C".
Maybe i did not understand the purpose of the Field "Allowed Companies" ( res.user.company_ids )
Solution for me: To make it work like expected i altered the access rules like this:
res.partner
['|','|','&',('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])]
res.company
[('id','in',[company.id for company in user.company_ids])]
But i am not sure if this has any impact or if this is the correct way to alter this access rules?!?
So my two questions are:
- What is the purpose of res.user.company_ids
- Are my new access rules correct and ok?