Hello,
My goal is to restrict user to access only Partners, which belong to the same company branch as the user.
User is linked to company branches through res_users.company_ids field, Partner is linked to company branch through res_partner.branch_id field.
Partner has an additional branch_id field for linking to company branch:
class ResPartner(orm.Model):
_inherit = 'res.partner'
_columns = {
'branch_id': fields.many2one('res.company', 'Branch'),
}
Access rule:
Access data of partners, which belong to branches that user is assigned to [('branch_id', 'in', [company.id for company in user.company_ids])]
This domain_forse expression does work well actually, but my concern is if it is right to do list comprehension, maybe there is another way to achieve this with expressions like 'child_of', etc. without list comprehension?
I have trouble figuring this out, as res_users.company_ids is a one2many.
Thank you in advance.
↧