some fields validation and model cleaning

This commit is contained in:
2025-08-05 21:38:16 +03:00
parent 06a3b105d3
commit f16ea7c748
130 changed files with 148 additions and 69 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+9 -1
View File
@@ -1,8 +1,12 @@
from django.db import models
from common.fields import ContainerNumberField
from containers.models import Container
# Create your models here.
class Preinfo(models.Model):
container_number = models.CharField(
container_number = ContainerNumberField(
max_length=11,
)
container_type = models.ForeignKey(
@@ -33,3 +37,7 @@ class Preinfo(models.Model):
)
deleted_on = models.DateTimeField(null=True, blank=True)
received = models.BooleanField(default=False, null=False)
def clean(self):
if Container.objects.filter(number=self.container_number, expedited=False).exists():
raise ValueError(f'Container with number {self.container_number} is at the depot.')
Binary file not shown.