diff --git a/apps/inm/migrations/0028_mioitem_count_tested.py b/apps/inm/migrations/0028_mioitem_count_tested.py new file mode 100644 index 00000000..b5c1cfee --- /dev/null +++ b/apps/inm/migrations/0028_mioitem_count_tested.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.12 on 2025-02-25 02:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('inm', '0027_alter_materialbatch_unique_together'), + ] + + operations = [ + migrations.AddField( + model_name='mioitem', + name='count_tested', + field=models.PositiveIntegerField(blank=True, null=True, verbose_name='已检数'), + ), + ] diff --git a/apps/inm/models.py b/apps/inm/models.py index c0244bd4..2775c183 100644 --- a/apps/inm/models.py +++ b/apps/inm/models.py @@ -118,7 +118,7 @@ class MIOItem(BaseModel): Material, verbose_name='物料', on_delete=models.CASCADE) batch = models.CharField('批次号', max_length=50) count = models.DecimalField('出入数量', max_digits=12, decimal_places=3) - + count_tested = models.PositiveIntegerField('已检数', null=True, blank=True) test_date = models.DateField('检验日期', null=True, blank=True) test_user = models.ForeignKey( User, verbose_name='检验人', on_delete=models.CASCADE, null=True, blank=True) diff --git a/apps/inm/views.py b/apps/inm/views.py index 625558fa..e9ede392 100644 --- a/apps/inm/views.py +++ b/apps/inm/views.py @@ -364,6 +364,7 @@ class MIOItemwViewSet(CustomModelViewSet): def cal_mioitem_count(self, mioitem:MIOItem): count = MIOItemw.objects.filter(mioitem=mioitem).count() mioitem.count = count + mioitem.count_tested = MIOItemw.objects.filter(mioitem=mioitem, ftest__isnull=False).count() mioitem.count_notok = MIOItemw.objects.filter(mioitem=mioitem, ftest__is_ok=False).count() mioitem.save()