fix - bug of edit distribution with parent
This commit is contained in:
@@ -86,8 +86,11 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
|
|||||||
if amount + total > self.instance.quota.quota_weight:
|
if amount + total > self.instance.quota.quota_weight:
|
||||||
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
||||||
else:
|
else:
|
||||||
if amount + total > self.instance.parent_distribution.weight:
|
children_total = self.instance.parent_distribution.children.all().aggregate(
|
||||||
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
total=models.Sum('weight')
|
||||||
|
)['total'] or 0
|
||||||
|
if children_total + amount > self.instance.parent_distribution.weight:
|
||||||
|
raise QuotaWeightException()
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,12 @@ class InventoryQuotaSaleTransactionSerializer(serializers.ModelSerializer):
|
|||||||
many=True
|
many=True
|
||||||
).data
|
).data
|
||||||
|
|
||||||
|
if instance.seller_organization:
|
||||||
|
representation['seller_organization'] = {
|
||||||
|
'id': instance.seller_organization.id,
|
||||||
|
'name': instance.seller_organization.name
|
||||||
|
}
|
||||||
|
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user