fix - related product quotas in admin account
This commit is contained in:
@@ -9,6 +9,7 @@ from rest_framework.decorators import action
|
|||||||
from rest_framework.exceptions import APIException
|
from rest_framework.exceptions import APIException
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
|
from apps.authentication.services.service import get_all_org_child
|
||||||
from apps.core.api import BaseViewSet
|
from apps.core.api import BaseViewSet
|
||||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||||
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
||||||
@@ -136,11 +137,19 @@ class ProductViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin,
|
|||||||
""" quotas that related to my organization and product """
|
""" quotas that related to my organization and product """
|
||||||
|
|
||||||
organization = get_organization_by_user(request.user)
|
organization = get_organization_by_user(request.user)
|
||||||
|
org_child = get_all_org_child(organization)
|
||||||
|
org_child.append(organization)
|
||||||
|
|
||||||
|
if organization.type.key == 'ADM':
|
||||||
|
quota = product_models.Quota.objects.filter(
|
||||||
|
product=self.get_object()
|
||||||
|
).distinct()
|
||||||
|
else:
|
||||||
quota = product_models.Quota.objects.filter(
|
quota = product_models.Quota.objects.filter(
|
||||||
Q(
|
Q(
|
||||||
distributions_assigned__in=product_models.QuotaDistribution.objects.filter(
|
distributions_assigned__in=product_models.QuotaDistribution.objects.filter(
|
||||||
Q(assigned_organization=organization) |
|
Q(assigned_organization__in=org_child) |
|
||||||
Q(assigner_organization=organization)
|
Q(assigner_organization__in=org_child)
|
||||||
)
|
)
|
||||||
) |
|
) |
|
||||||
Q(registerer_organization=organization),
|
Q(registerer_organization=organization),
|
||||||
|
|||||||
Reference in New Issue
Block a user