From 1b5b85a663b83858852c47be7e0da8caac03023c Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Mon, 14 Jul 2025 12:14:22 +0330 Subject: [PATCH] add weight types to live stovk types --- ...quotalivestockallocation_livestock_type.py | 17 ++++++++++++++++ ...quotalivestockallocation_livestock_type.py | 20 +++++++++++++++++++ apps/product/models.py | 8 +++++++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 apps/product/migrations/0044_remove_quotalivestockallocation_livestock_type.py create mode 100644 apps/product/migrations/0045_quotalivestockallocation_livestock_type.py diff --git a/apps/product/migrations/0044_remove_quotalivestockallocation_livestock_type.py b/apps/product/migrations/0044_remove_quotalivestockallocation_livestock_type.py new file mode 100644 index 0000000..b19b26a --- /dev/null +++ b/apps/product/migrations/0044_remove_quotalivestockallocation_livestock_type.py @@ -0,0 +1,17 @@ +# Generated by Django 5.0 on 2025-07-14 08:23 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('product', '0043_quota_sale_license'), + ] + + operations = [ + migrations.RemoveField( + model_name='quotalivestockallocation', + name='livestock_type', + ), + ] diff --git a/apps/product/migrations/0045_quotalivestockallocation_livestock_type.py b/apps/product/migrations/0045_quotalivestockallocation_livestock_type.py new file mode 100644 index 0000000..d1eae49 --- /dev/null +++ b/apps/product/migrations/0045_quotalivestockallocation_livestock_type.py @@ -0,0 +1,20 @@ +# Generated by Django 5.0 on 2025-07-14 08:25 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('livestock', '0012_livestocktype_weight_type'), + ('product', '0044_remove_quotalivestockallocation_livestock_type'), + ] + + operations = [ + migrations.AddField( + model_name='quotalivestockallocation', + name='livestock_type', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='allocations', to='livestock.livestocktype'), + ), + ] diff --git a/apps/product/models.py b/apps/product/models.py index 9167f45..05e8363 100644 --- a/apps/product/models.py +++ b/apps/product/models.py @@ -5,6 +5,7 @@ from apps.core.models import BaseModel from apps.authorization.models import UserRelations from apps.authentication.models import Organization from django.contrib.postgres.fields import ArrayField +from apps.livestock.models import LiveStockType from datetime import datetime import jdatetime @@ -428,7 +429,12 @@ class QuotaLivestockAllocation(BaseModel): null=True ) livestock_group = models.CharField(max_length=20, choices=LivestockGroup.choices, null=True) - livestock_type = models.CharField(max_length=20, choices=LivestockType.choices, null=True) + livestock_type = models.ForeignKey( + LiveStockType, + on_delete=models.CASCADE, + related_name='allocations', + null=True + ) livestock_subtype = models.CharField(max_length=20, choices=LivestockSubtype.choices, null=True) quantity_kg = models.DecimalField(max_digits=12, decimal_places=2, null=True)