From ea0fe7c3127709ee5d1db4c26557d0114ad02dbe Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 22 Jul 2026 16:20:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E7=89=A9=E6=96=99=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E6=A3=80=E9=AA=8C=E6=96=B9=E5=BC=8Ftest=5Fmo?= =?UTF-8?q?de=5Fin(=E5=85=8D=E6=A3=80/=E5=BF=85=E6=A3=80,=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=BF=85=E6=A3=80),=E7=94=9F=E4=BA=A7=E9=A2=86?= =?UTF-8?q?=E6=96=99=E6=A3=80=E9=AA=8C=E5=8D=A1=E7=82=B9=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=89=A9=E6=96=99=E7=BA=A7=E5=85=8D=E6=A3=80,=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E8=BF=87=E6=BB=A4=E5=99=A8=E6=94=AF=E6=8C=81material?= =?UTF-8?q?=5F=5Ftest=5Fmode=5Fin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- apps/inm/serializers.py | 5 +++-- apps/inm/views.py | 1 + .../migrations/0067_material_test_mode_in.py | 18 ++++++++++++++++++ apps/mtm/models.py | 11 +++++++++-- apps/mtm/serializers.py | 2 +- 5 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 apps/mtm/migrations/0067_material_test_mode_in.py diff --git a/apps/inm/serializers.py b/apps/inm/serializers.py index 5445dd6a..018673eb 100644 --- a/apps/inm/serializers.py +++ b/apps/inm/serializers.py @@ -188,9 +188,10 @@ class MIOItemCreateSerializer(CustomModelSerializer): if mio.state != MIO.MIO_CREATE: raise ParseError('出入库记录非创建中不可新增') # 生产领料要校验是否进行检验 - # 某些客户此处无需校验 + # 某些客户此处无需校验(全局总开关); 免检物料单独放行 check_test_when_do_out = get_sysconfig('mes.check_test_when_do_out', True) - if check_test_when_do_out and mio.type == MIO.MIO_TYPE_DO_OUT: + if (check_test_when_do_out and mio.type == MIO.MIO_TYPE_DO_OUT + and material.test_mode_in != Material.MA_TEST_EXEMPT): mis = MIOItem.objects.filter(batch=batch, material=material, mio__type__in=[MIO.MIO_TYPE_PUR_IN, MIO.MIO_TYPE_DO_IN, MIO.MIO_TYPE_OTHER_IN]) if mis.exists() and (not mis.exclude(test_date=None).exists()): raise ParseError('该批次的物料未经检验') diff --git a/apps/inm/views.py b/apps/inm/views.py index 07f9b513..8e96d177 100644 --- a/apps/inm/views.py +++ b/apps/inm/views.py @@ -379,6 +379,7 @@ class MIOItemViewSet(CustomListModelMixin, BulkCreateModelMixin, BulkDestroyMode "mio__inout_date": ["gte", "lte", "exact"], "material": ["exact"], "material__type": ["exact"], + "material__test_mode_in": ["exact"], "test_date": ["isnull", "exact"] } ordering = ['create_time'] diff --git a/apps/mtm/migrations/0067_material_test_mode_in.py b/apps/mtm/migrations/0067_material_test_mode_in.py new file mode 100644 index 00000000..ae8a02e1 --- /dev/null +++ b/apps/mtm/migrations/0067_material_test_mode_in.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.27 on 2026-07-22 07:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mtm', '0066_alter_process_clear_defect'), + ] + + operations = [ + migrations.AddField( + model_name='material', + name='test_mode_in', + field=models.PositiveSmallIntegerField(choices=[(10, '免检'), (20, '必检')], default=20, help_text='仓库入库后是否需要检验;免检物料生产领料时不校验', verbose_name='入库检验方式'), + ), + ] diff --git a/apps/mtm/models.py b/apps/mtm/models.py index 40155f8f..71875b4a 100644 --- a/apps/mtm/models.py +++ b/apps/mtm/models.py @@ -79,6 +79,9 @@ class Material(CommonAModel): MA_TRACKING_BATCH = 10 MA_TRACKING_SINGLE = 20 + MA_TEST_EXEMPT = 10 + MA_TEST_REQUIRED = 20 + name = models.CharField('名称', max_length=50) cate = models.CharField('大类', max_length=20, default='', blank=True) number = models.CharField('编号', max_length=100, null=True, blank=True) @@ -92,9 +95,13 @@ class Material(CommonAModel): testitems = models.JSONField('检测项目', default=list, blank=True) sort = models.FloatField('排序', default=1) unit = models.CharField('基准计量单位', default='个', max_length=10) - tracking = models.PositiveSmallIntegerField("追踪方式", default=10, - choices=((MA_TRACKING_BATCH, '批次'), + tracking = models.PositiveSmallIntegerField("追踪方式", default=10, + choices=((MA_TRACKING_BATCH, '批次'), (MA_TRACKING_SINGLE, '单件'))) + test_mode_in = models.PositiveSmallIntegerField('入库检验方式', default=20, + choices=((MA_TEST_EXEMPT, '免检'), + (MA_TEST_REQUIRED, '必检')), + help_text='仓库入库后是否需要检验;免检物料生产领料时不校验') # count = models.DecimalField('总库存', max_digits=14, decimal_places=3, default=0) # count_mb = models.DecimalField('仓库库存', max_digits=14, decimal_places=3, default=0) # count_wm = models.DecimalField('车间库存', max_digits=14, decimal_places=3, default=0) diff --git a/apps/mtm/serializers.py b/apps/mtm/serializers.py index e600f074..99beed56 100644 --- a/apps/mtm/serializers.py +++ b/apps/mtm/serializers.py @@ -24,7 +24,7 @@ class MaterialSimpleSerializer(CustomModelSerializer): class Meta: model = Material fields = ['id', 'name', 'number', 'model', - 'specification', 'type', 'cate', 'brothers', 'process_name', 'full_name', "tracking", "bin_number_main"] + 'specification', 'type', 'cate', 'brothers', 'process_name', 'full_name', "tracking", "bin_number_main", "test_mode_in"] def get_full_name(self, obj): return f'{obj.name}|{obj.specification if obj.specification else ""}|{obj.model if obj.model else ""}|{obj.process.name if obj.process else ""}'