feat: init_by_qct
This commit is contained in:
parent
8eddeb4f70
commit
22ff47a6ba
|
@ -5,6 +5,7 @@ from apps.mtm.models import Material, Shift
|
||||||
from apps.em.models import Equipment
|
from apps.em.models import Equipment
|
||||||
from apps.wpm.models import SfLog, WMaterial
|
from apps.wpm.models import SfLog, WMaterial
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.db import transaction
|
||||||
|
|
||||||
class Defect(CommonAModel):
|
class Defect(CommonAModel):
|
||||||
# 缺陷项
|
# 缺陷项
|
||||||
|
@ -261,6 +262,16 @@ class Ftest(CommonBDModel):
|
||||||
def ftestdefects(self):
|
def ftestdefects(self):
|
||||||
return FtestDefect.objects.filter(ftest=self)
|
return FtestDefect.objects.filter(ftest=self)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def init_by_qct(cls, qct, test_user, test_date):
|
||||||
|
with transaction.atomic():
|
||||||
|
ftest = Ftest.objects.create(qct=qct, test_user=test_user, test_date=test_date)
|
||||||
|
for testitem in qct.testitems.all():
|
||||||
|
FtestItem.objects.create(ftest=ftest, testitem=testitem)
|
||||||
|
for defect in qct.defects.all():
|
||||||
|
FtestDefect.objects.create(ftest=ftest, defect=defect)
|
||||||
|
return ftest
|
||||||
|
|
||||||
|
|
||||||
class FtestItem(BaseModel):
|
class FtestItem(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue