feat: 交接记录在审批状态下对撤销的处理

This commit is contained in:
caoqianming 2025-08-18 16:52:23 +08:00
parent fbce5ec64f
commit 0dab1714f3
2 changed files with 5 additions and 3 deletions

View File

@ -14,6 +14,7 @@ from apps.mtm.models import Mgroup, Shift, Material, Route, RoutePack, Team, Sru
from .models import SfLog, WMaterial, Mlog, Mlogb, Mlogbw, Handover, Handoverb, Handoverbw, MlogbDefect, BatchLog, BatchSt
from apps.mtm.services_2 import cal_material_count
from apps.wf.models import Ticket
from apps.wf.services import WfService
import logging
from apps.wpm.services_2 import ana_batch_thread, ana_wpr_thread
from datetime import timedelta
@ -935,12 +936,13 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
ana_batch_thread(xbatchs=batches)
def handover_revert(handover:Handover):
def handover_revert(handover:Handover, handler:User):
if handover.submit_time is None:
raise ParseError('该交接单未提交!')
ticket:Ticket = handover.ticket
if ticket:
raise ParseError('该交接单已关联审批,暂不支持撤销!')
# 首先把ticket改回开始状态
WfService.retreat(ticket=ticket, suggestion="撤销交接单", handler=handler, next_handler=handover.create_by)
mids = []
# handover_type = handover.type
# handover_mtype = handover.mtype

View File

@ -504,7 +504,7 @@ class HandoverViewSet(CustomModelViewSet):
"""
ins: Handover = self.get_object()
if ins.submit_time:
handover_revert(ins)
handover_revert(ins, handle_user=request.user)
return Response()
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=HandoverMgroupSerializer)