fix agencie share on pos device - fix validation bug of free product pos
This commit is contained in:
@@ -19,8 +19,13 @@ class POSFreeProductSerializer(serializers.ModelSerializer):
|
||||
|
||||
product = attrs['product']
|
||||
organization = attrs['organization']
|
||||
device = self.context['device']
|
||||
|
||||
if self.Meta.model.objects.filter(organization=organization, product=product).exists():
|
||||
if self.Meta.model.objects.filter(
|
||||
organization=organization,
|
||||
product=product,
|
||||
device=device
|
||||
).exists():
|
||||
raise FreePOSProductUniqueCheck()
|
||||
|
||||
return attrs
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from apps.product.services.services import quota_live_stock_allocation_info, quota_incentive_plans_info, \
|
||||
quota_attribute_value
|
||||
quota_attribute_value, quota_pricing_items_by_type
|
||||
from apps.herd.services.services import get_rancher_statistics, rancher_quota_weight
|
||||
from apps.pos_device.services.services import pos_organizations_sharing_information
|
||||
from rest_framework.exceptions import APIException
|
||||
@@ -116,20 +116,10 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
|
||||
'sharing': pos_organizations_sharing_information(
|
||||
device,
|
||||
instance.quota,
|
||||
distribution=instance
|
||||
distribution=instance,
|
||||
owner_org=organization
|
||||
),
|
||||
'base_prices': [
|
||||
{
|
||||
"text": "قیمت درب کارخانه", # noqa
|
||||
"name": "base_price_factory",
|
||||
"value": instance.quota.base_price_factory
|
||||
},
|
||||
{
|
||||
"text": "قیمت درب اتحادیه", # noqa
|
||||
"name": "base_price_cooperative",
|
||||
"value": instance.quota.base_price_cooperative
|
||||
}
|
||||
]
|
||||
'base_prices': quota_pricing_items_by_type(instance.quota)
|
||||
}
|
||||
|
||||
if 'rancher' in self.context.keys():
|
||||
|
||||
@@ -107,7 +107,7 @@ class POSFreeProductsViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSear
|
||||
'device': device.id,
|
||||
})
|
||||
|
||||
serializer = product_serializers.POSFreeProductSerializer(data=request.data)
|
||||
serializer = product_serializers.POSFreeProductSerializer(data=request.data, context={'device': device})
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user