add sale license to quota
This commit is contained in:
19
apps/product/migrations/0043_quota_sale_license.py
Normal file
19
apps/product/migrations/0043_quota_sale_license.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-07-13 06:58
|
||||||
|
|
||||||
|
import django.contrib.postgres.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('product', '0042_alter_incentiveplan_unique_together'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='quota',
|
||||||
|
name='sale_license',
|
||||||
|
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), null=True, size=None),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -308,6 +308,7 @@ class Quota(BaseModel):
|
|||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
month_choices = ArrayField(base_field=models.IntegerField(), null=True)
|
month_choices = ArrayField(base_field=models.IntegerField(), null=True)
|
||||||
|
sale_license = ArrayField(base_field=models.IntegerField(), null=True)
|
||||||
group = models.CharField(
|
group = models.CharField(
|
||||||
max_length=50,
|
max_length=50,
|
||||||
choices=[("rural", "روستایی"), ("industrial", "صنعتی"), ("nomadic", "عشایری")] # noqa
|
choices=[("rural", "روستایی"), ("industrial", "صنعتی"), ("nomadic", "عشایری")] # noqa
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class QuotaSerializer(serializers.ModelSerializer):
|
|||||||
instance.sale_type = validated_data.get('sale_type', instance.sale_type)
|
instance.sale_type = validated_data.get('sale_type', instance.sale_type)
|
||||||
instance.sale_unit = validated_data.get('sale_unit', instance.sale_type)
|
instance.sale_unit = validated_data.get('sale_unit', instance.sale_type)
|
||||||
instance.month_choices = validated_data.get('month_choices', instance.month_choices)
|
instance.month_choices = validated_data.get('month_choices', instance.month_choices)
|
||||||
|
instance.sale_license = validated_data.get('sale_license', instance.sale_license)
|
||||||
instance.group = validated_data.get('group', instance.group)
|
instance.group = validated_data.get('group', instance.group)
|
||||||
instance.has_distribution_limit = validated_data.get('has_distribution_limit', instance.has_distribution_limit)
|
instance.has_distribution_limit = validated_data.get('has_distribution_limit', instance.has_distribution_limit)
|
||||||
instance.distribution_mode = validated_data.get('distribution_mode', instance.distribution_mode)
|
instance.distribution_mode = validated_data.get('distribution_mode', instance.distribution_mode)
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ def delete(queryset, pk):
|
|||||||
class ProductCategoryViewSet(viewsets.ModelViewSet):
|
class ProductCategoryViewSet(viewsets.ModelViewSet):
|
||||||
queryset = product_models.ProductCategory.objects.all()
|
queryset = product_models.ProductCategory.objects.all()
|
||||||
serializer_class = product_serializers.ProductCategorySerializer
|
serializer_class = product_serializers.ProductCategorySerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['type', 'name']
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
methods=['put'],
|
methods=['put'],
|
||||||
@@ -63,6 +65,8 @@ class ProductCategoryViewSet(viewsets.ModelViewSet):
|
|||||||
class ProductViewSet(viewsets.ModelViewSet):
|
class ProductViewSet(viewsets.ModelViewSet):
|
||||||
queryset = product_models.Product.objects.all()
|
queryset = product_models.Product.objects.all()
|
||||||
serializer_class = product_serializers.ProductSerializer
|
serializer_class = product_serializers.ProductSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['type', 'name']
|
||||||
|
|
||||||
def list(self, request, *args, **kwargs):
|
def list(self, request, *args, **kwargs):
|
||||||
""" custom list view """ #
|
""" custom list view """ #
|
||||||
@@ -114,6 +118,8 @@ class AttributeViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = product_models.Attribute.objects.all()
|
queryset = product_models.Attribute.objects.all()
|
||||||
serializer_class = product_serializers.AttributeSerializer
|
serializer_class = product_serializers.AttributeSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['name']
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
methods=['put'],
|
methods=['put'],
|
||||||
@@ -190,6 +196,8 @@ class BrokerViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = product_models.Broker.objects.all()
|
queryset = product_models.Broker.objects.all()
|
||||||
serializer_class = product_serializers.BrokerSerializer
|
serializer_class = product_serializers.BrokerSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['broker_type', 'name']
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
methods=['put'],
|
methods=['put'],
|
||||||
@@ -228,6 +236,8 @@ class SaleUnitViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = product_models.SaleUnit.objects.all()
|
queryset = product_models.SaleUnit.objects.all()
|
||||||
serializer_class = product_serializers.SaleUnitSerializer
|
serializer_class = product_serializers.SaleUnitSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['unit']
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
methods=['put'],
|
methods=['put'],
|
||||||
@@ -272,6 +282,7 @@ class IncentivePlanViewSet(viewsets.ModelViewSet): # noqa
|
|||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
""" custom incentive plan create object """
|
""" custom incentive plan create object """
|
||||||
|
|
||||||
# set incentive plans with user relations like organization
|
# set incentive plans with user relations like organization
|
||||||
user_relation = product_models.UserRelations.objects.filter(user=request.user).first()
|
user_relation = product_models.UserRelations.objects.filter(user=request.user).first()
|
||||||
request.data['registering_organization'] = user_relation.id
|
request.data['registering_organization'] = user_relation.id
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from apps.product import models as product_models
|
|||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from common.tools import CustomOperations
|
from common.tools import CustomOperations
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets, filters
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
@@ -34,6 +34,8 @@ class QuotaViewSet(viewsets.ModelViewSet): # noqa
|
|||||||
|
|
||||||
queryset = product_models.Quota.objects.all()
|
queryset = product_models.Quota.objects.all()
|
||||||
serializer_class = quota_serializers.QuotaSerializer
|
serializer_class = quota_serializers.QuotaSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['']
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from rest_framework.exceptions import APIException
|
|||||||
from apps.product import models as product_models
|
from apps.product import models as product_models
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets, filters
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
|
||||||
@@ -26,6 +26,8 @@ class QuotaDistributionViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = product_models.QuotaDistribution.objects.all()
|
queryset = product_models.QuotaDistribution.objects.all()
|
||||||
serializer_class = distribution_serializers.QuotaDistributionSerializer
|
serializer_class = distribution_serializers.QuotaDistributionSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['']
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from apps.warehouse.web.api.v1 import serializers as warehouse_serializers
|
|||||||
from apps.warehouse import models as warehouse_models
|
from apps.warehouse import models as warehouse_models
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets, filters
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
|
|
||||||
@@ -10,8 +10,12 @@ from rest_framework import status
|
|||||||
class InventoryEntryViewSet(viewsets.ModelViewSet):
|
class InventoryEntryViewSet(viewsets.ModelViewSet):
|
||||||
queryset = warehouse_models.InventoryEntry.objects.all()
|
queryset = warehouse_models.InventoryEntry.objects.all()
|
||||||
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['']
|
||||||
|
|
||||||
|
|
||||||
class InventoryQuotaSaleTransactionViewSet(viewsets.ModelViewSet):
|
class InventoryQuotaSaleTransactionViewSet(viewsets.ModelViewSet):
|
||||||
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
||||||
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['']
|
||||||
|
|||||||
Reference in New Issue
Block a user