If you can't build a dynamic access to the partner or product with the standard record rules, perhaps you may use the search_read method, which offer a more flexible and dynamic way to control the domain.
Example below is in the example by inherit the res.partner and implement the search_read method to generate the dynamic domain.
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
user = self.env.user
user_is_billing_manager = user.has_group('account.group_account_manager')
user_is_billing_user = user.has_group('account.group_account_invoice')
if user_is_billing_manager:
domain = []
elif user_is_billing_user:
domain = [('is_vip', '=', True), ('cs_rep.id', '=', user.id)]
domain = expression.AND([domain, add_domain])
return super(ResPartner, self).search_read(domain=domain, fields=fields, offset=offset, limit=limit,
order=order)
Comments