feat: mlog 变化不再创建日志
This commit is contained in:
parent
84f7de61bc
commit
d52bd4e064
|
@ -160,17 +160,17 @@ class MlogViewSet(CustomModelViewSet):
|
|||
'material_in__number', 'material_in__specification', 'batch', 'material_in__model',
|
||||
'material_out__name', 'material_out__number', 'material_out__specification', 'material_out__model',]
|
||||
|
||||
@transaction.atomic
|
||||
def perform_create(self, serializer):
|
||||
ins = serializer.save()
|
||||
data = MlogSerializer(ins).data
|
||||
create_auditlog('create', ins, data)
|
||||
# @transaction.atomic
|
||||
# def perform_create(self, serializer):
|
||||
# ins = serializer.save()
|
||||
# data = MlogSerializer(ins).data
|
||||
# create_auditlog('create', ins, data)
|
||||
|
||||
@transaction.atomic
|
||||
def perform_destroy(self, instance):
|
||||
if instance.submit_time is not None:
|
||||
raise ParseError('日志已提交不可变动')
|
||||
delete_auditlog(instance, instance.id)
|
||||
# delete_auditlog(instance, instance.id)
|
||||
instance.delete()
|
||||
|
||||
@transaction.atomic
|
||||
|
@ -178,10 +178,10 @@ class MlogViewSet(CustomModelViewSet):
|
|||
ins = serializer.instance
|
||||
if ins.submit_time is not None:
|
||||
raise ParseError('该日志已提交!')
|
||||
val_old = MlogSerializer(instance=ins).data
|
||||
# val_old = MlogSerializer(instance=ins).data
|
||||
serializer.save()
|
||||
val_new = MlogSerializer(instance=ins).data
|
||||
create_auditlog('update', ins, val_new, val_old)
|
||||
# val_new = MlogSerializer(instance=ins).data
|
||||
# create_auditlog('update', ins, val_new, val_old)
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post': 'mlog.init'}, serializer_class=MlogInitSerializer)
|
||||
def init(self, request, *args, **kwargs):
|
||||
|
@ -213,7 +213,6 @@ class MlogViewSet(CustomModelViewSet):
|
|||
日志提交
|
||||
"""
|
||||
ins: Mlog = self.get_object()
|
||||
vdata_old = MlogSerializer(ins).data
|
||||
now = timezone.now()
|
||||
if ins.ticket:
|
||||
raise ParseError('该日志存在审批!')
|
||||
|
@ -225,8 +224,8 @@ class MlogViewSet(CustomModelViewSet):
|
|||
with transaction.atomic():
|
||||
mlog_submit(ins, self.request.user, now)
|
||||
vdata_new = MlogSerializer(ins).data
|
||||
create_auditlog('submit', ins, vdata_new,
|
||||
vdata_old, now, self.request.user)
|
||||
# create_auditlog('submit', ins, vdata_new,
|
||||
# vdata_old, now, self.request.user)
|
||||
MyThread(target=cal_mtask_progress_from_mlog,args=(ins,)).start()
|
||||
MyThread(target=cal_material_count_from_mlog,args=(ins,)).start()
|
||||
return Response(vdata_new)
|
||||
|
@ -246,8 +245,8 @@ class MlogViewSet(CustomModelViewSet):
|
|||
now = timezone.now()
|
||||
with transaction.atomic():
|
||||
mlog_revert(ins, user, now)
|
||||
create_auditlog('revert', ins, {}, {}, now, user,
|
||||
request.data.get('change_reason', ''))
|
||||
# create_auditlog('revert', ins, {}, {}, now, user,
|
||||
# request.data.get('change_reason', ''))
|
||||
MyThread(target=cal_mtask_progress_from_mlog,args=(ins,)).start()
|
||||
MyThread(target=cal_material_count_from_mlog,args=(ins,)).start()
|
||||
return Response(MlogSerializer(instance=ins).data)
|
||||
|
|
Loading…
Reference in New Issue