forked from erp-dev/erp
fix: added created_by_name into printing order detail api
This commit is contained in:
@@ -196,6 +196,7 @@ class PrintingOrderDetailSerializer(serializers.ModelSerializer):
|
|||||||
customer_phone = serializers.CharField(source='customer.mobile', read_only=True)
|
customer_phone = serializers.CharField(source='customer.mobile', read_only=True)
|
||||||
customer_area = serializers.CharField(source='customer.area', read_only=True)
|
customer_area = serializers.CharField(source='customer.area', read_only=True)
|
||||||
process_name = serializers.CharField(source='process.name', read_only=True)
|
process_name = serializers.CharField(source='process.name', read_only=True)
|
||||||
|
created_by_name = serializers.SerializerMethodField()
|
||||||
progress = serializers.IntegerField(read_only=True)
|
progress = serializers.IntegerField(read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -204,13 +205,21 @@ class PrintingOrderDetailSerializer(serializers.ModelSerializer):
|
|||||||
'id', 'human_id', 'customer', 'customer_name', 'customer_phone', 'customer_area',
|
'id', 'human_id', 'customer', 'customer_name', 'customer_phone', 'customer_area',
|
||||||
'fabric', 'width', 'is_urgent', 'area', 'address', 'fabric_source',
|
'fabric', 'width', 'is_urgent', 'area', 'address', 'fabric_source',
|
||||||
'is_fabric_received', 'craft', 'description', 'outgoing_date',
|
'is_fabric_received', 'craft', 'description', 'outgoing_date',
|
||||||
'curve', 'new_curve', 'position',
|
'curve', 'new_curve', 'position', 'created_by_name',
|
||||||
'printing_warn', 'rolling_warn', 'production_warn',
|
'printing_warn', 'rolling_warn', 'production_warn',
|
||||||
'is_invalid', 'process', 'process_name', 'progress', 'print_count',
|
'is_invalid', 'process', 'process_name', 'progress', 'print_count',
|
||||||
'created_at', 'updated_at'
|
'created_at', 'updated_at'
|
||||||
]
|
]
|
||||||
read_only_fields = ['id', 'human_id', 'created_at', 'updated_at', 'progress', 'print_count']
|
read_only_fields = ['id', 'human_id', 'created_at', 'updated_at', 'progress', 'print_count']
|
||||||
|
|
||||||
|
def get_created_by_name(self, obj):
|
||||||
|
"""获取创建人名称(员工姓名)"""
|
||||||
|
user = getattr(obj, 'created_by', None)
|
||||||
|
if not user:
|
||||||
|
return None
|
||||||
|
emp = getattr(user, 'employee', None)
|
||||||
|
return getattr(emp, 'name', None)
|
||||||
|
|
||||||
|
|
||||||
class PrintingOrderCreateUpdateSerializer(serializers.ModelSerializer):
|
class PrintingOrderCreateUpdateSerializer(serializers.ModelSerializer):
|
||||||
"""印染订单创建/更新序列化器"""
|
"""印染订单创建/更新序列化器"""
|
||||||
|
|||||||
Reference in New Issue
Block a user