diff --git a/apps/qm/filters.py b/apps/qm/filters.py index 1ac42ff8..162c793e 100644 --- a/apps/qm/filters.py +++ b/apps/qm/filters.py @@ -34,5 +34,6 @@ class FtestWorkFilter(filters.FilterSet): "mb": ["exact"], "batch": ["exact"], "type": ["exact"], - "type2": ["exact"], + "type2": ["exact"], + "shift": ["exact"] } \ No newline at end of file diff --git a/apps/qm/migrations/0024_ftestwork_shift.py b/apps/qm/migrations/0024_ftestwork_shift.py new file mode 100644 index 00000000..7743caaa --- /dev/null +++ b/apps/qm/migrations/0024_ftestwork_shift.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.12 on 2024-09-11 08:28 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('mtm', '0041_process_mstate_json'), + ('qm', '0023_ftestwork_need_update_wm'), + ] + + operations = [ + migrations.AddField( + model_name='ftestwork', + name='shift', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='mtm.shift', verbose_name='班次'), + ), + ] diff --git a/apps/qm/models.py b/apps/qm/models.py index 3501ae2e..d69b2854 100644 --- a/apps/qm/models.py +++ b/apps/qm/models.py @@ -1,7 +1,7 @@ from django.db import models from apps.system.models import CommonAModel, CommonADModel, User from apps.utils.models import CommonBDModel, BaseModel -from apps.mtm.models import Material, Mgroup, Team +from apps.mtm.models import Material, Mgroup, Team, Shift from apps.wpm.models import SfLog, WMaterial from django.utils.translation import gettext_lazy as _ @@ -111,6 +111,7 @@ class FtestWork(CommonBDModel): """ type = models.CharField('检验类型', max_length=20, choices=FTEST_TYPE_CHOICES, default='prod') type2 = models.PositiveSmallIntegerField('检验类型2', choices=((10, '抽检'), (20, '全检')), default=10) + shift = models.ForeignKey(Shift, verbose_name='班次', on_delete=models.SET_NULL, null=True, blank=True) wm = models.ForeignKey(WMaterial, verbose_name='关联车间库存', on_delete=models.SET_NULL, null=True, blank=True) mb = models.ForeignKey('inm.materialbatch', verbose_name='关联仓库', on_delete=models.SET_NULL, null=True, blank=True) test_date = models.DateField('检验日期') diff --git a/apps/qm/serializers.py b/apps/qm/serializers.py index ddde6b20..68a8b368 100644 --- a/apps/qm/serializers.py +++ b/apps/qm/serializers.py @@ -63,7 +63,7 @@ class QuaStatUpdateSerializer(CustomModelSerializer): class FtestWorkCreateUpdateSerializer(CustomModelSerializer): class Meta: model = FtestWork - fields = ['id', 'wm', 'mb', 'type', 'type2', 'test_date', 'count', 'count_sampling', 'count_sampling_ok', 'count_ok', 'count_notok', 'count_notok_json', 'test_user', 'need_update_wm'] + fields = ['id', 'shift', 'wm', 'mb', 'type', 'type2', 'test_date', 'count', 'count_sampling', 'count_sampling_ok', 'count_ok', 'count_notok', 'count_notok_json', 'test_user', 'need_update_wm'] extra_kwargs = {'test_user': {'required': True}, 'type': {'required': True}} def validate(self, attrs):