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:
|
||||
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
||||
else:
|
||||
if amount + total > self.instance.parent_distribution.weight:
|
||||
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
||||
children_total = self.instance.parent_distribution.children.all().aggregate(
|
||||
total=models.Sum('weight')
|
||||
)['total'] or 0
|
||||
if children_total + amount > self.instance.parent_distribution.weight:
|
||||
raise QuotaWeightException()
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@@ -104,6 +104,12 @@ class InventoryQuotaSaleTransactionSerializer(serializers.ModelSerializer):
|
||||
many=True
|
||||
).data
|
||||
|
||||
if instance.seller_organization:
|
||||
representation['seller_organization'] = {
|
||||
'id': instance.seller_organization.id,
|
||||
'name': instance.seller_organization.name
|
||||
}
|
||||
|
||||
return representation
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user