transaction serializer
This commit is contained in:
@@ -27,7 +27,6 @@ class BaseViewSet(RegionFilterMixin, viewsets.ModelViewSet):
|
|||||||
if visibility_by_org_scope:
|
if visibility_by_org_scope:
|
||||||
""" if organization has free visibility by scope, apply visibility filter """
|
""" if organization has free visibility by scope, apply visibility filter """
|
||||||
queryset = apply_visibility_filter(queryset, org)
|
queryset = apply_visibility_filter(queryset, org)
|
||||||
print("ssssssssssssss")
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
if user_relation.exists():
|
if user_relation.exists():
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ VISIBILITY_MAP = {
|
|||||||
'productstats': 'organization',
|
'productstats': 'organization',
|
||||||
'quotadistribution': ['assigner_organization', 'assigned_organization'],
|
'quotadistribution': ['assigner_organization', 'assigned_organization'],
|
||||||
'inventoryentry': 'organization',
|
'inventoryentry': 'organization',
|
||||||
'inventoryquotasaletransaction': 'organization',
|
'inventoryquotasaletransaction': 'seller_organization',
|
||||||
'device': 'organization',
|
'device': 'organization',
|
||||||
|
|
||||||
# 'deviceactivationcode': 'organization',
|
# 'deviceactivationcode': 'organization',
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class InventoryEntryViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet,
|
|||||||
return self.get_paginated_response(serializer.data)
|
return self.get_paginated_response(serializer.data)
|
||||||
|
|
||||||
|
|
||||||
class InventoryQuotaSaleTransactionViewSet(SoftDeleteMixin, DynamicSearchMixin, BaseViewSet, viewsets.ModelViewSet):
|
class InventoryQuotaSaleTransactionViewSet(BaseViewSet, SoftDeleteMixin, DynamicSearchMixin, viewsets.ModelViewSet):
|
||||||
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
||||||
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
||||||
filter_backends = [filters.SearchFilter]
|
filter_backends = [filters.SearchFilter]
|
||||||
@@ -147,7 +147,14 @@ class InventoryQuotaSaleTransactionViewSet(SoftDeleteMixin, DynamicSearchMixin,
|
|||||||
list of transactions
|
list of transactions
|
||||||
filter by: search, all, my_transactions
|
filter by: search, all, my_transactions
|
||||||
"""
|
"""
|
||||||
queryset = self.filter_query(self.get_queryset())
|
print("ssss")
|
||||||
|
queryset = self.filter_query(self.get_queryset(visibility_by_org_scope=True))
|
||||||
|
|
||||||
|
# paginate & response
|
||||||
|
page = self.paginate_queryset(queryset)
|
||||||
|
if page is not None: # noqa
|
||||||
|
serializer = self.get_serializer(page, many=True)
|
||||||
|
return self.get_paginated_response(serializer.data)
|
||||||
|
|
||||||
|
|
||||||
class InventoryQuotaSaleItemViewSet(SoftDeleteMixin, BaseViewSet, viewsets.ModelViewSet):
|
class InventoryQuotaSaleItemViewSet(SoftDeleteMixin, BaseViewSet, viewsets.ModelViewSet):
|
||||||
|
|||||||
@@ -95,6 +95,17 @@ class InventoryQuotaSaleTransactionSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
def to_representation(self, instance):
|
||||||
|
""" custom output of inventory sale transaction serializer """
|
||||||
|
|
||||||
|
representation = super().to_representation(instance)
|
||||||
|
representation['items'] = InventoryQuotaSaleItemSerializer(
|
||||||
|
instance.items.all(),
|
||||||
|
many=True
|
||||||
|
).data
|
||||||
|
|
||||||
|
return representation
|
||||||
|
|
||||||
|
|
||||||
class InventoryQuotaSaleItemSerializer(serializers.ModelSerializer):
|
class InventoryQuotaSaleItemSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
Reference in New Issue
Block a user