some changes in inventory serializer - creted date & distribution data
This commit is contained in:
@@ -14,6 +14,8 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
||||
model = warehouse_models.InventoryEntry
|
||||
fields = [
|
||||
"id",
|
||||
"create_date",
|
||||
"modify_date",
|
||||
"distribution",
|
||||
"weight",
|
||||
"lading_number",
|
||||
@@ -22,17 +24,6 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
||||
"notes",
|
||||
]
|
||||
|
||||
def create(self, validated_data):
|
||||
""" Custom create & set organization """
|
||||
|
||||
distribution = validated_data['distribution']
|
||||
organization = distribution.assigned_organization
|
||||
|
||||
return warehouse_models.InventoryEntry.objects.create(
|
||||
organization=organization,
|
||||
**validated_data
|
||||
)
|
||||
|
||||
def validate(self, attrs):
|
||||
"""
|
||||
check if inventory entries weight is not more than
|
||||
@@ -58,6 +49,8 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
||||
def to_representation(self, instance):
|
||||
representation = super().to_representation(instance)
|
||||
representation['document'] = instance.document
|
||||
if instance.distribution:
|
||||
representation['distribution'] = instance.distribution.distribution_id
|
||||
|
||||
return representation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user