visit belong_dept 默认公司

This commit is contained in:
caoqianming 2022-11-01 13:52:12 +08:00
parent d9190abdd5
commit 10f19272eb
1 changed files with 3 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from wsgiref.validate import validator from wsgiref.validate import validator
from apps.hrm.serializers import EmployeeSimpleSerializer from apps.hrm.serializers import EmployeeSimpleSerializer
from apps.system.models import Dept
from apps.utils.fields import MyFilePathField from apps.utils.fields import MyFilePathField
from apps.utils.serializers import CustomModelSerializer from apps.utils.serializers import CustomModelSerializer
from apps.utils.tools import check_id_number_e, check_phone_e from apps.utils.tools import check_id_number_e, check_phone_e
@ -26,6 +27,8 @@ class VisitCreateUpdateSerializer(CustomModelSerializer):
if receptionist.type != 'employee': if receptionist.type != 'employee':
raise ParseError('接待人需为正式员工') raise ParseError('接待人需为正式员工')
validated_data['belong_dept'] = validated_data['receptionist'].belong_dept validated_data['belong_dept'] = validated_data['receptionist'].belong_dept
else:
validated_data['belong_dept'] = Dept.objects.all().order_by('create_time').first()
return super().create(validated_data) return super().create(validated_data)
def update(self, instance, validated_data): def update(self, instance, validated_data):