import - tag batch / batch items

This commit is contained in:
2026-01-06 16:55:33 +03:30
parent d1de26e002
commit 89c794bf81

View File

@@ -4,6 +4,7 @@ from django.db import models
from jdatetime import datetime
from apps.authentication import models as auth_models
from apps.authentication.models import Organization
from apps.core.models import BaseModel
from apps.tag.tools import tag_code_serial_scanning
@@ -51,10 +52,53 @@ class Tag(BaseModel):
super(Tag, self).save(*args, **kwargs)
# class TagBatch(BaseModel):
# organization = models.ForeignKey(
#
# )
class TagBatch(BaseModel):
organization = models.ForeignKey(
Organization,
on_delete=models.CASCADE,
related_name='tag_batches',
null=True
)
request_number = models.CharField(
max_length=50,
default="0",
null=True
)
status = models.CharField(
max_length=20,
choices=[
('created', 'CREATED'),
('distributed', 'DISTRIBUTED'),
('created', 'CREATED'),
],
null=True,
default='created'
)
description = models.TextField(null=True, blank=True)
def __str__(self):
return f'{self.id}-{self.request_number}-{self.organization.name}'
def save(self, *args, **kwargs):
return super(TagBatch, self).save(*args, **kwargs)
class TagBatchItem(BaseModel):
batch = models.ForeignKey(
TagBatch,
on_delete=models.CASCADE,
related_name='items',
null=True
)
tag = models.ManyToManyField(Tag, related_name='tags')
species_code = models.IntegerField(default=0)
serial_from = models.PositiveBigIntegerField(default=0)
serial_to = models.PositiveBigIntegerField(default=0)
count = models.IntegerField(default=0)
def __str__(self):
return f"id:{self.id}-batch:{self.batch.id}-code:{self.species_code}"
class TagAssignment(BaseModel):