feat: mioitem添加count_tested
This commit is contained in:
parent
32ba222523
commit
0e96485fae
|
@ -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='已检数'),
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue