feat: route支持传入material_out_tracking
This commit is contained in:
parent
39eef7d2b4
commit
d1c15b0b2e
|
@ -163,6 +163,7 @@ class RouteSerializer(CustomModelSerializer):
|
||||||
source='material_out.type', read_only=True)
|
source='material_out.type', read_only=True)
|
||||||
material_out_is_hidden = serializers.BooleanField(
|
material_out_is_hidden = serializers.BooleanField(
|
||||||
source='material_out.is_hidden', read_only=True)
|
source='material_out.is_hidden', read_only=True)
|
||||||
|
material_out_tracking = serializers.IntegerField(source='material_out.tracking')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Route
|
model = Route
|
||||||
|
@ -181,7 +182,7 @@ class RouteSerializer(CustomModelSerializer):
|
||||||
raise ParseError('切分数量必须大于1')
|
raise ParseError('切分数量必须大于1')
|
||||||
return super().validate(attrs)
|
return super().validate(attrs)
|
||||||
|
|
||||||
def gen_material_out(self, instance: Route):
|
def gen_material_out(self, instance: Route, material_out_tracking:int):
|
||||||
"""
|
"""
|
||||||
自动形成物料
|
自动形成物料
|
||||||
"""
|
"""
|
||||||
|
@ -195,7 +196,7 @@ class RouteSerializer(CustomModelSerializer):
|
||||||
material_out.model = material.model
|
material_out.model = material.model
|
||||||
material_out.specification = material.specification
|
material_out.specification = material.specification
|
||||||
material_out.cate = material.cate
|
material_out.cate = material.cate
|
||||||
material_out.tracking = material.tracking
|
material_out.tracking = material_out_tracking
|
||||||
material_out.save()
|
material_out.save()
|
||||||
instance.material_out = material_out
|
instance.material_out = material_out
|
||||||
instance.save()
|
instance.save()
|
||||||
|
@ -206,7 +207,7 @@ class RouteSerializer(CustomModelSerializer):
|
||||||
if material_out.parent is None:
|
if material_out.parent is None:
|
||||||
material_out.parent = material
|
material_out.parent = material
|
||||||
material_out.cate = material.cate
|
material_out.cate = material.cate
|
||||||
material_out.tracking = material.tracking
|
material_out.tracking = material_out_tracking
|
||||||
material_out.save()
|
material_out.save()
|
||||||
instance.material_out = material_out
|
instance.material_out = material_out
|
||||||
instance.save()
|
instance.save()
|
||||||
|
@ -218,7 +219,7 @@ class RouteSerializer(CustomModelSerializer):
|
||||||
'model': material.model,
|
'model': material.model,
|
||||||
'type': Material.MA_TYPE_HALFGOOD,
|
'type': Material.MA_TYPE_HALFGOOD,
|
||||||
'cate': material.cate,
|
'cate': material.cate,
|
||||||
'tracking': material.tracking,
|
'tracking': material_out_tracking,
|
||||||
'create_by': self.request.user,
|
'create_by': self.request.user,
|
||||||
'update_by': self.request.user,
|
'update_by': self.request.user,
|
||||||
})
|
})
|
||||||
|
@ -249,7 +250,7 @@ class RouteSerializer(CustomModelSerializer):
|
||||||
raise ParseError('物料工序错误!请重新选择')
|
raise ParseError('物料工序错误!请重新选择')
|
||||||
else:
|
else:
|
||||||
if instance.material:
|
if instance.material:
|
||||||
self.gen_material_out(instance)
|
self.gen_material_out(instance, validated_data.get("material_out_tracking", Material.MA_TRACKING_BATCH))
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
|
@ -268,7 +269,7 @@ class RouteSerializer(CustomModelSerializer):
|
||||||
raise ParseError('物料工序错误!请重新选择')
|
raise ParseError('物料工序错误!请重新选择')
|
||||||
else:
|
else:
|
||||||
if instance.material:
|
if instance.material:
|
||||||
self.gen_material_out(instance)
|
self.gen_material_out(instance, validated_data.get("material_out_tracking", Material.MA_TRACKING_BATCH))
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue