fix - bug of edit price features in distribution
This commit is contained in:
@@ -86,8 +86,6 @@ class QuotaStatsService:
|
||||
@staticmethod
|
||||
def update_distribution(distribution: QuotaDistribution, old_weight: int):
|
||||
diff = distribution.weight - old_weight
|
||||
if diff == 0:
|
||||
return
|
||||
|
||||
quota = distribution.quota
|
||||
|
||||
@@ -110,6 +108,14 @@ class QuotaStatsService:
|
||||
organization=assigned,
|
||||
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 diff > 0 it is added to destination
|
||||
assigner_stat.remaining_amount -= diff
|
||||
@@ -119,10 +125,6 @@ class QuotaStatsService:
|
||||
assigned_stat.remaining_amount += diff
|
||||
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
|
||||
def delete_distribution(distribution: QuotaDistribution):
|
||||
quota = distribution.quota
|
||||
|
||||
@@ -66,6 +66,14 @@ def update_quota_remaining(sender, instance, **kwargs):
|
||||
if getattr(instance, '_from_signal', False):
|
||||
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):
|
||||
""" update all stats of product """
|
||||
|
||||
Reference in New Issue
Block a user