fix --> bug of calculate remaining tags of distribution parent batch

This commit is contained in:
2026-02-02 11:24:37 +03:30
parent 74a870380e
commit 0dd145131f

View File

@@ -53,14 +53,17 @@ def calculate_tag_distribution_detail(sender, instance: TagDistributionBatch, **
tag_dist_batch = instance tag_dist_batch = instance
parent = tag_dist_batch.parent parent = tag_dist_batch.parent
if parent: if parent:
# parent.total_distributed_tag_count += tag_dist_batch.total_tag_count parent.total_distributed_tag_count += tag_dist_batch.total_tag_count
parent.remaining_tag_count = 20 parent.remaining_tag_count = (
print(parent.remaining_tag_count) parent.total_tag_count - parent.total_distributed_tag_count
parent.save(update_fields=['remaining_tag_count']) )
parent.parent_flag = True
parent.save(update_fields=['remaining_tag_count', 'total_distributed_tag_count'])
tag_dist_batch.remaining_tag_count = tag_dist_batch.total_tag_count if not getattr(instance, 'parent_flag', False):
instance.flag = True tag_dist_batch.remaining_tag_count = tag_dist_batch.total_tag_count
tag_dist_batch.save(update_fields=['remaining_tag_count']) instance.flag = True
tag_dist_batch.save(update_fields=['remaining_tag_count'])
# @receiver(m2m_changed, sender=TagDistribution.tag.through) # @receiver(m2m_changed, sender=TagDistribution.tag.through)
# def on_tags_added_to_distribution(sender, instance, action, pk_set, **kwargs): # def on_tags_added_to_distribution(sender, instance, action, pk_set, **kwargs):