首件检验bug
This commit is contained in:
parent
7355253ff8
commit
847986027a
|
@ -10,7 +10,7 @@ def update_all_employee_not_atwork():
|
||||||
"""
|
"""
|
||||||
将所有员工设为非在岗状态
|
将所有员工设为非在岗状态
|
||||||
"""
|
"""
|
||||||
Employee.objects.all().update(is_atwork=False, last_check_time = None)
|
Employee.objects.all().update(is_atwork=False, last_check_time = None, not_work_remark=None)
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def update_all_user_facedata_cache():
|
def update_all_user_facedata_cache():
|
||||||
|
|
|
@ -40,7 +40,7 @@ class PackItemViewSet(CreateUpdateModelAMixin, ModelViewSet):
|
||||||
queryset = PackItem.objects.all()
|
queryset = PackItem.objects.all()
|
||||||
serializer_class = PackItemSerializer
|
serializer_class = PackItemSerializer
|
||||||
search_fields = ['name', 'number']
|
search_fields = ['name', 'number']
|
||||||
filterset_fields = ['material']
|
filterset_fields = ['material', 'product']
|
||||||
ordering = ['sort']
|
ordering = ['sort']
|
||||||
|
|
||||||
def get_serializer_class(self):
|
def get_serializer_class(self):
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.2.9 on 2022-02-22 01:58
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('qm', '0026_alter_testrecord_is_testok'),
|
||||||
|
('pm', '0027_auto_20220221_1027'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='subproductionplan',
|
||||||
|
name='first_test',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='qm.testrecord'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.2.9 on 2022-02-22 02:45
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('qm', '0026_alter_testrecord_is_testok'),
|
||||||
|
('pm', '0028_alter_subproductionplan_first_test'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='subproductionplan',
|
||||||
|
name='first_test',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='qm.testrecord', verbose_name='首件检验'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
from apps.qm.models import TestRecord
|
||||||
from apps.system.models import CommonAModel, Organization, User
|
from apps.system.models import CommonAModel, Organization, User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import AbstractUser
|
from django.contrib.auth.models import AbstractUser
|
||||||
|
@ -92,7 +93,8 @@ class SubProductionPlan(CommonAModel):
|
||||||
end_date_real = models.DateField('实际完工日期', null=True, blank=True)
|
end_date_real = models.DateField('实际完工日期', null=True, blank=True)
|
||||||
is_picked = models.BooleanField('是否已领料', default=False)
|
is_picked = models.BooleanField('是否已领料', default=False)
|
||||||
|
|
||||||
first_test = models.ForeignKey('qm.testrecord', on_delete=models.CASCADE, null=True, blank=True)
|
first_test = models.ForeignKey('qm.testrecord', on_delete=models.SET_NULL,
|
||||||
|
null=True, blank=True, verbose_name='首件检验')
|
||||||
leader_1 = models.ForeignKey(User, on_delete=models.CASCADE,
|
leader_1 = models.ForeignKey(User, on_delete=models.CASCADE,
|
||||||
verbose_name="工序负责人", null=True, blank=True, related_name='first_leader_1')
|
verbose_name="工序负责人", null=True, blank=True, related_name='first_leader_1')
|
||||||
leader_2 = models.ForeignKey(User, on_delete=models.CASCADE,
|
leader_2 = models.ForeignKey(User, on_delete=models.CASCADE,
|
||||||
|
@ -105,6 +107,10 @@ class SubProductionPlan(CommonAModel):
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = '子生产计划'
|
verbose_name = '子生产计划'
|
||||||
verbose_name_plural = verbose_name
|
verbose_name_plural = verbose_name
|
||||||
|
|
||||||
|
# @property
|
||||||
|
# def first_test(self):
|
||||||
|
# return self.test_subplan.filter(type=TestRecord.TEST_FIRST, is_deleted=False).first()
|
||||||
|
|
||||||
class SubProductionProgress(BaseModel):
|
class SubProductionProgress(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from apps.mtm.models import RecordForm
|
from apps.mtm.models import RecordForm
|
||||||
from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress
|
from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
from apps.qm.models import TestRecord
|
||||||
from apps.qm.serializers import TestRecordShortSerializer
|
from apps.qm.serializers import TestRecordShortSerializer
|
||||||
from apps.sam.serializers import OrderSerializer, OrderSimpleSerializer
|
from apps.sam.serializers import OrderSerializer, OrderSimpleSerializer
|
||||||
from apps.mtm.serializers import MaterialSimpleSerializer, ProcessSimpleSerializer, RecordFormSimpleSerializer, SubProductionSimpleSerializer
|
from apps.mtm.serializers import MaterialSimpleSerializer, ProcessSimpleSerializer, RecordFormSimpleSerializer, SubProductionSimpleSerializer
|
||||||
|
@ -44,6 +45,7 @@ class SubProductionPlanListSerializer(DynamicFieldsSerializerMixin, serializers.
|
||||||
leader_2_ = UserSimpleSerializer(source='leader_2', read_only=True)
|
leader_2_ = UserSimpleSerializer(source='leader_2', read_only=True)
|
||||||
leader_3_ = UserSimpleSerializer(source='leader_3', read_only=True)
|
leader_3_ = UserSimpleSerializer(source='leader_3', read_only=True)
|
||||||
first_test_ = TestRecordShortSerializer(source='first_test', read_only=True)
|
first_test_ = TestRecordShortSerializer(source='first_test', read_only=True)
|
||||||
|
# first_test_ = serializers.SerializerMethodField()
|
||||||
class Meta:
|
class Meta:
|
||||||
model=SubProductionPlan
|
model=SubProductionPlan
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
@ -51,7 +53,10 @@ class SubProductionPlanListSerializer(DynamicFieldsSerializerMixin, serializers.
|
||||||
def get_plan_product_(self, obj):
|
def get_plan_product_(self, obj):
|
||||||
return MaterialSimpleSerializer(instance=obj.production_plan.product).data
|
return MaterialSimpleSerializer(instance=obj.production_plan.product).data
|
||||||
|
|
||||||
|
# def get_first_test_(self, obj):
|
||||||
|
# if obj.first_test:
|
||||||
|
# return TestRecordShortSerializer(instance=obj.first_test).data
|
||||||
|
# return None
|
||||||
|
|
||||||
|
|
||||||
class SubProductionPlanUpdateSerializer(serializers.ModelSerializer):
|
class SubProductionPlanUpdateSerializer(serializers.ModelSerializer):
|
||||||
|
|
|
@ -152,7 +152,7 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
|
||||||
perms_map = {'get': '*', 'put':'subplan_update'}
|
perms_map = {'get': '*', 'put':'subplan_update'}
|
||||||
queryset = SubProductionPlan.objects.select_related('process',
|
queryset = SubProductionPlan.objects.select_related('process',
|
||||||
'workshop', 'subproduction', 'product',
|
'workshop', 'subproduction', 'product',
|
||||||
'production_plan__product', 'leader_1', 'leader_2', 'leader_3')
|
'production_plan__product', 'leader_1', 'leader_2', 'leader_3', 'first_test')
|
||||||
search_fields = []
|
search_fields = []
|
||||||
serializer_class = SubProductionPlanListSerializer
|
serializer_class = SubProductionPlanListSerializer
|
||||||
filterset_fields = ['production_plan', 'process', 'state', 'product', 'workshop']
|
filterset_fields = ['production_plan', 'process', 'state', 'product', 'workshop']
|
||||||
|
@ -243,7 +243,10 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
|
||||||
首件检查表初始化
|
首件检查表初始化
|
||||||
"""
|
"""
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
if obj.first_test is None:
|
first_test = obj.first_test
|
||||||
|
if first_test:
|
||||||
|
return Response(TestRecordDetailBaseSerializer(instance=first_test).data)
|
||||||
|
else:
|
||||||
rdata = request.data
|
rdata = request.data
|
||||||
serializer = self.get_serializer(data=rdata)
|
serializer = self.get_serializer(data=rdata)
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
|
@ -264,7 +267,6 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
|
||||||
obj.first_test = tr
|
obj.first_test = tr
|
||||||
obj.save()
|
obj.save()
|
||||||
return Response(TestRecordDetailBaseSerializer(instance=tr).data)
|
return Response(TestRecordDetailBaseSerializer(instance=tr).data)
|
||||||
raise APIException('首件检查已存在')
|
|
||||||
|
|
||||||
@action(methods=['post'], detail=True, perms_map={'post':'first_test_audit'}, serializer_class=FirstTestAuditSerializer)
|
@action(methods=['post'], detail=True, perms_map={'post':'first_test_audit'}, serializer_class=FirstTestAuditSerializer)
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.2.9 on 2022-02-22 02:45
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('pm', '0029_alter_subproductionplan_first_test'),
|
||||||
|
('qm', '0026_alter_testrecord_is_testok'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='testrecord',
|
||||||
|
name='subproduction_plan',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='test_subplan', to='pm.subproductionplan', verbose_name='关联的生产子计划'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -66,7 +66,7 @@ class TestRecord(CommonADModel):
|
||||||
wproduct = models.ForeignKey('wpm.wproduct', verbose_name='关联的动态产品', on_delete=models.CASCADE, null=True, blank=True, related_name='test_wproduct')
|
wproduct = models.ForeignKey('wpm.wproduct', verbose_name='关联的动态产品', on_delete=models.CASCADE, null=True, blank=True, related_name='test_wproduct')
|
||||||
material = models.ForeignKey('mtm.material', verbose_name='关联的物料状态', on_delete=models.CASCADE, null=True, blank=True)
|
material = models.ForeignKey('mtm.material', verbose_name='关联的物料状态', on_delete=models.CASCADE, null=True, blank=True)
|
||||||
step = models.ForeignKey('mtm.step', verbose_name='关联的工序步骤', on_delete=models.CASCADE, null=True, blank=True)
|
step = models.ForeignKey('mtm.step', verbose_name='关联的工序步骤', on_delete=models.CASCADE, null=True, blank=True)
|
||||||
subproduction_plan = models.ForeignKey('pm.subproductionplan', verbose_name='关联的生产子计划', on_delete=models.CASCADE, null=True, blank=True)
|
subproduction_plan = models.ForeignKey('pm.subproductionplan', verbose_name='关联的生产子计划', on_delete=models.CASCADE, null=True, blank=True, related_name='test_subplan')
|
||||||
fifo_item = models.ForeignKey('inm.fifoitem', verbose_name='关联的出入库批次', on_delete=models.CASCADE, null=True, blank=True)
|
fifo_item = models.ForeignKey('inm.fifoitem', verbose_name='关联的出入库批次', on_delete=models.CASCADE, null=True, blank=True)
|
||||||
origin_test = models.ForeignKey('self', verbose_name='原检验记录', on_delete=models.CASCADE, null=True, blank=True)
|
origin_test = models.ForeignKey('self', verbose_name='原检验记录', on_delete=models.CASCADE, null=True, blank=True)
|
||||||
is_submited = models.BooleanField('是否提交', default=False)
|
is_submited = models.BooleanField('是否提交', default=False)
|
||||||
|
|
Loading…
Reference in New Issue