add - whole system of inventory entry in organization quotas stat

This commit is contained in:
2025-11-19 15:56:15 +03:30
parent 42c01f3eb5
commit 1bf6950ccb
9 changed files with 152 additions and 34 deletions

View File

@@ -19,6 +19,12 @@ class InventoryEntry(BaseModel):
related_name='inventory_entry',
null=True
)
quota = models.ForeignKey(
product_models.Quota,
on_delete=models.CASCADE,
related_name='inventory_entry',
null=True
)
organization = models.ForeignKey(
product_models.Organization,
on_delete=models.CASCADE,
@@ -38,7 +44,7 @@ class InventoryEntry(BaseModel):
# prefix = "POS"
while True:
number_part = ''.join(random.choices(string.digits, k=6))
code = f"{self.distribution.quota.quota_id}{number_part}"
code = f"{self.quota.quota_id}{number_part}"
if not InventoryEntry.objects.filter(entry_identity=code).exists():
return code