ixg_platform/apps/capa/models.py

29 lines
1.1 KiB
Python

import uuid
from django.db import models
class CAPARecord(models.Model):
class Status(models.TextChoices):
OPEN = "open", "Open"
IN_PROGRESS = "in_progress", "In Progress"
CLOSED = "closed", "Closed"
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
batch = models.ForeignKey("batches.ProcessingBatch", on_delete=models.CASCADE, related_name="capa_records")
issue_description = models.TextField()
root_cause = models.TextField(blank=True)
corrective_action = models.TextField(blank=True)
preventive_action = models.TextField(blank=True)
status = models.CharField(max_length=20, choices=Status.choices, default=Status.OPEN)
assigned_to = models.CharField(max_length=255, blank=True)
due_date = models.DateField(null=True, blank=True)
closed_at = models.DateTimeField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = "capa_records"
verbose_name = "CAPA Record"
verbose_name_plural = "CAPA Records"
def __str__(self):
return f"CAPA {self.batch.batch_reference} - {self.status}"