fix - bug of edit price features in distribution
This commit is contained in:
@@ -86,8 +86,6 @@ class QuotaStatsService:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def update_distribution(distribution: QuotaDistribution, old_weight: int):
|
def update_distribution(distribution: QuotaDistribution, old_weight: int):
|
||||||
diff = distribution.weight - old_weight
|
diff = distribution.weight - old_weight
|
||||||
if diff == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
quota = distribution.quota
|
quota = distribution.quota
|
||||||
|
|
||||||
@@ -110,6 +108,14 @@ class QuotaStatsService:
|
|||||||
organization=assigned,
|
organization=assigned,
|
||||||
quota=quota
|
quota=quota
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# create pricing attributes and broker pricing data
|
||||||
|
data = json.loads(get_current_request_body().decode())
|
||||||
|
import_price_features(data, assigned_stat, quota)
|
||||||
|
|
||||||
|
if diff == 0:
|
||||||
|
return
|
||||||
|
|
||||||
if assigner_stat.stat_type == 'distribution':
|
if assigner_stat.stat_type == 'distribution':
|
||||||
# if diff > 0 it is added to destination
|
# if diff > 0 it is added to destination
|
||||||
assigner_stat.remaining_amount -= diff
|
assigner_stat.remaining_amount -= diff
|
||||||
@@ -119,10 +125,6 @@ class QuotaStatsService:
|
|||||||
assigned_stat.remaining_amount += diff
|
assigned_stat.remaining_amount += diff
|
||||||
assigned_stat.save()
|
assigned_stat.save()
|
||||||
|
|
||||||
# create pricing attributes and broker pricing data
|
|
||||||
data = json.loads(get_current_request_body().decode())
|
|
||||||
import_price_features(data, assigned_stat, quota)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def delete_distribution(distribution: QuotaDistribution):
|
def delete_distribution(distribution: QuotaDistribution):
|
||||||
quota = distribution.quota
|
quota = distribution.quota
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ def update_quota_remaining(sender, instance, **kwargs):
|
|||||||
if getattr(instance, '_from_signal', False):
|
if getattr(instance, '_from_signal', False):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# when delete object, prevent from update fields error
|
||||||
|
# if kwargs.get('signal') == post_delete:
|
||||||
|
if instance.trash:
|
||||||
|
if instance.parent_distribution:
|
||||||
|
remaining_distribution_weight(instance.parent_distribution)
|
||||||
|
else:
|
||||||
|
remaining_distribution_weight(instance)
|
||||||
|
|
||||||
|
|
||||||
def update_product_stats(instance: Product, distribution: QuotaDistribution = None):
|
def update_product_stats(instance: Product, distribution: QuotaDistribution = None):
|
||||||
""" update all stats of product """
|
""" update all stats of product """
|
||||||
|
|||||||
Reference in New Issue
Block a user