change: change StockMovemendCreateSerializer

This commit is contained in:
behruz-dev
2025-08-29 11:15:41 +05:00
parent 7c31a393f2
commit 56ee227a68
2 changed files with 3 additions and 2 deletions

View File

@@ -59,6 +59,7 @@ class StockMovmendCreateSerializer(serializers.Serializer):
comment=validated_data.get('comment'), comment=validated_data.get('comment'),
wherehouse_to=validated_data.get('wherehouse_to'), wherehouse_to=validated_data.get('wherehouse_to'),
wherehouse_from=validated_data.get('wherehouse_from'), wherehouse_from=validated_data.get('wherehouse_from'),
recipient=self.context.get('user'),
) )
movmend_products = [] movmend_products = []
for product in products: for product in products:
@@ -84,8 +85,8 @@ class StockMovemendProductListSerializer(serializers.ModelSerializer):
def get_product(self, obj): def get_product(self, obj):
return { return {
'id': obj.inventory.product.id, 'id': obj.inventory.product.id,
'name': obj.inventory.product.name,
'type': obj.inventory.product.type, 'type': obj.inventory.product.type,
'name': obj.inventory.product.name,
} }
def get_unity(self, obj): def get_unity(self, obj):

View File

@@ -19,7 +19,7 @@ class StockMovemendCreateApiView(generics.GenericAPIView):
required_permissions = [] required_permissions = []
def post(self, request): def post(self, request):
serializer = self.serializer_class(data=request.data) serializer = self.serializer_class(data=request.data, context={'user': request.user})
if serializer.is_valid(raise_exception=True): if serializer.is_valid(raise_exception=True):
serializer.save() serializer.save()
return Response( return Response(