Models.py
:
from django.db import models
from database_app.models import Add_Part,Add_Sub_Assy,Add_Defect_category,Add_Contractor_or_Supplier,Add_Process
Models.py
class Ncr(models.Model):
date = models.DateTimeField(default=timezone.now())
Process = models.ForeignKey(Add_Process_or_Function,on_delete=models.CASCADE,null=True)
Lot_qty=models.IntegerField()
qty = models.IntegerField()
def occ_rating(self):
ppm=self.qty/self.Lot_qty*1000000
if ppm >=1 and ppm < 10:
return int(2)
else:
return int(1)
Fmea Модель:
from database_app.models import Add_Process_or_Function,Add_Part
class Fmea(models.Model):
date = models.DateField(default=timezone.now())
Process = models.ForeignKey(Add_Process_or_Function,on_delete=models.CASCADE,blank=True,null=True)
функция, необходимая для получения данных от модели ncr
def occ_rating(self)
if self.Process == NCR.Process:
return occ_rating