top of page
  • Writer's pictureTek Siong, Hock

Odoo control access with the search_read method

Updated: Apr 5

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.

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), ('', '=',]
    domain = expression.AND([domain, add_domain])
    return super(ResPartner, self).search_read(domain=domain, fields=fields, offset=offset, limit=limit,
27 views0 comments

Recent Posts

See All

Let the AI answer your questions based on your Odoo data

bottom of page