def filter_products(queryset, user):
    if user.is_staff:
        return queryset

    return queryset.filter(stockrecords__partner__users__pk=user.pk).distinct()
Restrict the queryset to products the given user has access to.
dataset/ETHPy150Open django-oscar/django-oscar/src/oscar/apps/dashboard/catalogue/views.py/filter_products