[FIX] BASE: Restrict Group users_count to selected company context

This commit is contained in:
Horilla
2025-07-07 11:40:23 +05:30
parent 67bce92d0e
commit a4d062cb4c
2 changed files with 12 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import pandas as pd
import pdfkit
from django.apps import apps
from django.conf import settings
from django.contrib.auth.models import Group
from django.contrib.staticfiles import finders
from django.core.exceptions import ObjectDoesNotExist
from django.core.paginator import Paginator
@@ -27,6 +28,16 @@ from horilla.horilla_middlewares import _thread_locals
from horilla.horilla_settings import HORILLA_DATE_FORMATS, HORILLA_TIME_FORMATS
def users_count(self):
"""
Restrict Group users_count to selected company context
"""
return Employee.objects.filter(employee_user_id__in=self.user_set.all()).count()
Group.add_to_class("users_count", property(users_count))
def filtersubordinates(request, queryset, perm=None, field="employee_id"):
"""
This method is used to filter out subordinates queryset element.