feat: mlogchange支持work_start_time
This commit is contained in:
parent
45af751350
commit
28671451b0
|
@ -639,8 +639,6 @@ class MlogSerializer(CustomModelSerializer):
|
||||||
attrs['handle_date'] = mtask.end_date
|
attrs['handle_date'] = mtask.end_date
|
||||||
if attrs['handle_date'] != handle_date:
|
if attrs['handle_date'] != handle_date:
|
||||||
raise ParseError('任务日期与生产日期不一致')
|
raise ParseError('任务日期与生产日期不一致')
|
||||||
else:
|
|
||||||
attrs['handle_date'] = handle_date
|
|
||||||
else:
|
else:
|
||||||
attrs['handle_date'] = handle_date
|
attrs['handle_date'] = handle_date
|
||||||
|
|
||||||
|
@ -688,8 +686,6 @@ class MlogInitSerializer(CustomModelSerializer):
|
||||||
supplier = attrs.get('supplier', None)
|
supplier = attrs.get('supplier', None)
|
||||||
if not supplier:
|
if not supplier:
|
||||||
raise ParseError('外协必须选择外协单位')
|
raise ParseError('外协必须选择外协单位')
|
||||||
if attrs.get('work_start_time', None) and 'handle_date' not in attrs:
|
|
||||||
attrs['handle_date'] = localdate(attrs['work_end_time'])
|
|
||||||
# 如果已经确定产出,则自动获取qct
|
# 如果已经确定产出,则自动获取qct
|
||||||
if attrs.get("material_out", None):
|
if attrs.get("material_out", None):
|
||||||
attrs["qct"] = Qct.get(attrs["material_out"], "process", "out")
|
attrs["qct"] = Qct.get(attrs["material_out"], "process", "out")
|
||||||
|
@ -700,12 +696,14 @@ class MlogInitSerializer(CustomModelSerializer):
|
||||||
class MlogChangeSerializer(CustomModelSerializer):
|
class MlogChangeSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Mlog
|
model = Mlog
|
||||||
fields = ['id', 'work_end_time', 'handle_user', 'note', 'oinfo_json', 'test_file', 'test_user', 'test_time', 'equipment', "team"]
|
fields = ['id', 'work_start_time', 'work_end_time', 'handle_user', 'note', 'oinfo_json', 'test_file', 'test_user', 'test_time', 'equipment', "team"]
|
||||||
|
|
||||||
# def validate(self, attrs):
|
def update(self, instance, validated_data):
|
||||||
# if attrs.get('work_end_time', None):
|
work_start_time = validated_data.get('work_start_time', None)
|
||||||
# attrs['handle_date'] = localdate(attrs['work_end_time'])
|
if work_start_time:
|
||||||
# return attrs
|
mgroup:Mgroup = instance.mgroup
|
||||||
|
validated_data["handle_date"], validated_data["shift"] = mgroup.get_shift(work_start_time)
|
||||||
|
return super().update(instance, validated_data)
|
||||||
|
|
||||||
|
|
||||||
class CountJsonSerializer(serializers.Serializer):
|
class CountJsonSerializer(serializers.Serializer):
|
||||||
|
|
Loading…
Reference in New Issue