wproduct 增加need_to_order字段
This commit is contained in:
parent
4ba365b243
commit
e90213d6ce
|
@ -51,6 +51,7 @@ class MaterialBatchSerializer(serializers.ModelSerializer):
|
|||
class IProductListSerializer(serializers.ModelSerializer):
|
||||
material_ = MaterialSimpleSerializer(source='material', read_only=True)
|
||||
warehouse_ = WareHouseSimpleSerializer(source='warehouse', read_only=True)
|
||||
need_to_order = serializers.BooleanField(source='wproduct.need_to_order', read_only=True)
|
||||
is_mtestok = serializers.BooleanField(source='wproduct.is_mtestok', read_only=True)
|
||||
remark_mtest = serializers.CharField(source='wproduct.remark_mtest', read_only=True)
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class WProductFilterSet(DynamicFieldsFilterMixin, filters.FilterSet):
|
|||
class Meta:
|
||||
model = WProduct
|
||||
fields = ['step', 'subproduction_plan', 'material',
|
||||
'step__process', 'act_state', 'material__type']
|
||||
'step__process', 'act_state', 'material__type', 'need_to_order']
|
||||
|
||||
def filter_tag(self, queryset, name, value):
|
||||
if value == 'no_scrap':
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# Generated by Django 3.2.9 on 2022-01-25 03:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wpm', '0051_auto_20220120_1541'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='wproduct',
|
||||
name='is_mtested',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='wproductflow',
|
||||
name='is_mtested',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='wproduct',
|
||||
name='need_to_order',
|
||||
field=models.BooleanField(default=False, verbose_name='是否要指派订单'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='wproductflow',
|
||||
name='need_to_order',
|
||||
field=models.BooleanField(default=False, verbose_name='是否要指派订单'),
|
||||
),
|
||||
]
|
|
@ -119,6 +119,7 @@ class WProduct(CommonAModel):
|
|||
ticket = models.ForeignKey('wf.ticket', verbose_name='当前工单',
|
||||
on_delete=models.SET_NULL, null=True, blank=True, related_name='wp_ticket')
|
||||
|
||||
need_to_order = models.BooleanField('是否要指派订单', default=False)
|
||||
to_order = models.ForeignKey('sam.order', verbose_name='指派的订单', null=True, blank=True, on_delete = models.CASCADE)
|
||||
is_mtestok = models.BooleanField('是否军检合格', null=True, blank=True)
|
||||
remark_mtest = models.TextField('军检备注', null=True, blank=True)
|
||||
|
@ -192,6 +193,8 @@ class WproductFlow(CommonAModel):
|
|||
on_delete=models.SET_NULL, null=True, blank=True)
|
||||
ticket = models.ForeignKey('wf.ticket', verbose_name='当前工单',
|
||||
on_delete=models.SET_NULL, null=True, blank=True)
|
||||
|
||||
need_to_order = models.BooleanField('是否要指派订单', default=False)
|
||||
to_order = models.ForeignKey('sam.order', verbose_name='指派的订单', null=True, blank=True, on_delete = models.CASCADE)
|
||||
is_mtestok = models.BooleanField('是否军检合格', null=True, blank=True)
|
||||
remark_mtest = models.TextField('军检备注', null=True, blank=True)
|
||||
|
|
|
@ -441,6 +441,24 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
|
|||
ret.append([str(index + 1), item['step_name'], item['actions']])
|
||||
return Response(ret)
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=WproductToOrderSerializer)
|
||||
@transaction.atomic
|
||||
def need_to_order(self, request, pk=None):
|
||||
"""
|
||||
设为需要指派订单
|
||||
"""
|
||||
serializer = WproductToOrderSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
vdata = serializer.validated_data
|
||||
wps = WProduct.objects.filter(id__in = [i.id for i in vdata.get('wproducts')])
|
||||
wps.update()
|
||||
for i in wps:
|
||||
i.need_to_order = True
|
||||
i.update_by = request.user
|
||||
i.save()
|
||||
WpmServies.add_wproduct_flow_log(i, change_str='need_to_order')
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=WproductToOrderSerializer)
|
||||
@transaction.atomic
|
||||
def to_order(self, request, pk=None):
|
||||
|
@ -451,6 +469,8 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
|
|||
serializer.is_valid(raise_exception=True)
|
||||
vdata = serializer.validated_data
|
||||
wps = WProduct.objects.filter(id__in = [i.id for i in vdata.get('wproducts')])
|
||||
if wps.filter(need_to_order = False).exists():
|
||||
raise exceptions.ValidationError('存在不需要指派订单的产品')
|
||||
wp = wps.first()
|
||||
order = vdata['order']
|
||||
if wp.material != order.product:
|
||||
|
|
Loading…
Reference in New Issue