feat: MlogbIn create时同步创建out
This commit is contained in:
parent
2d522a1fd4
commit
5ad15c0a9e
|
@ -447,3 +447,21 @@ class MlogbInViewSet(CreateModelMixin, DestroyModelMixin, CustomGenericViewSet):
|
||||||
perms_map = {'post': 'mlog.update', 'delete': 'mlog.update'}
|
perms_map = {'post': 'mlog.update', 'delete': 'mlog.update'}
|
||||||
queryset = Mlogb.objects.all()
|
queryset = Mlogb.objects.all()
|
||||||
serializer_class = MlogbInSerializer
|
serializer_class = MlogbInSerializer
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
|
def perform_create(self, serializer):
|
||||||
|
ins: Mlogb = serializer.save()
|
||||||
|
# 创建输出
|
||||||
|
if ins.mtask:
|
||||||
|
material_out = ins.mlog.material_out
|
||||||
|
route = ins.mlog.route
|
||||||
|
if material_out is None:
|
||||||
|
raise ParseError('产物不可为空')
|
||||||
|
m_dict = {
|
||||||
|
"mtask": ins.mtask,
|
||||||
|
"mlog": ins.mlog,
|
||||||
|
"material_out": ins.mlog.material_out
|
||||||
|
}
|
||||||
|
if route.batch_bind: # 批次绑定
|
||||||
|
m_dict['batch'] = ins.batch
|
||||||
|
Mlogb.objects.get_or_create(**m_dict, defaults=m_dict)
|
||||||
|
|
Loading…
Reference in New Issue