fix destroy of distribution
This commit is contained in:
@@ -156,7 +156,9 @@ class QuotaDistributionViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSe
|
|||||||
quota_distribution = self.get_object()
|
quota_distribution = self.get_object()
|
||||||
|
|
||||||
# check if distribution has inventory entry
|
# check if distribution has inventory entry
|
||||||
if quota_distribution.inventory_entry.exists() and quota_distribution.parent_distribution is not None:
|
if quota_distribution.inventory_entry.exists() or self.queryset.filter(
|
||||||
|
parent_distribution=quota_distribution.id
|
||||||
|
):
|
||||||
raise APIException(
|
raise APIException(
|
||||||
"امکان حذف این توزیع وجود ندارد. ورود به انبار یا توزیعی برای آن ثبت شده است", # noqa
|
"امکان حذف این توزیع وجود ندارد. ورود به انبار یا توزیعی برای آن ثبت شده است", # noqa
|
||||||
status.HTTP_400_BAD_REQUEST
|
status.HTTP_400_BAD_REQUEST
|
||||||
|
|||||||
Reference in New Issue
Block a user