fix - edit price features in quota

This commit is contained in:
2025-12-03 10:51:01 +03:30
parent a5635c278f
commit d024d7fd7b
3 changed files with 29 additions and 19 deletions

View File

@@ -197,14 +197,18 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicS
quota.attribute_values.all().delete()
for attr in request.data['price_attributes_data']:
# create new relations
attr.update({'quota': quota.id})
attributes = CustomOperations().custom_create(
request=request,
view=product_api.AttributeValueViewSet(),
data=attr
)
attributes_value_list.append(attributes)
for stat in quota.org_quota_stats.all():
# create new relations
attr.update({
'quota': quota.id,
'org_quota_stat': stat.id if stat.stat_type != 'quota' else None
})
attributes = CustomOperations().custom_create(
request=request,
view=product_api.AttributeValueViewSet(),
data=attr
)
attributes_value_list.append(attributes)
# create product broker values for quota
broker_data_list = [] # noqa
@@ -214,14 +218,18 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicS
quota.broker_values.all().delete()
for broker in request.data['broker_data']:
# create new relations
broker.update({'quota': quota.id})
broker_value = CustomOperations().custom_create(
request=request,
view=QuotaBrokerValueViewSet(),
data=broker
)
broker_data_list.append(broker_value)
for stat in quota.org_quota_stats.all():
# create new relations
broker.update({
'quota': quota.id,
'org_quota_stat': stat.id if stat.stat_type != 'quota' else None
})
broker_value = CustomOperations().custom_create(
request=request,
view=QuotaBrokerValueViewSet(),
data=broker
)
broker_data_list.append(broker_value)
# create livestock allocations to quota
allocations_list = []