fix inventory balanve & remaining - import provider name in device serializer
This commit is contained in:
@@ -35,7 +35,13 @@ def remaining_distribution_weight(instance: QuotaDistribution):
|
||||
total_children_weight = instance.children.aggregate(
|
||||
total=Sum('weight')
|
||||
)['total'] or 0
|
||||
instance.remaining_weight = instance.weight - total_children_weight
|
||||
|
||||
# total warehouse inventory entry
|
||||
total_entry = instance.inventory_entry.aggregate(
|
||||
total=Sum('weight')
|
||||
)['total'] or 0
|
||||
|
||||
instance.remaining_weight = instance.weight - total_children_weight - total_entry
|
||||
instance.distributed = total_children_weight
|
||||
instance._from_signal = True
|
||||
instance.save(update_fields=['remaining_weight', 'distributed'])
|
||||
|
||||
Reference in New Issue
Block a user