diff --git a/app_new/equipments/main.py b/app_new/equipments/main.py index 5f2b34e..cfed467 100644 --- a/app_new/equipments/main.py +++ b/app_new/equipments/main.py @@ -118,7 +118,16 @@ def index(): # uniquement lorsque l'utilisateur déplie une famille. for parent in parents: parent.zones_list = [] - parent.individual_count = parent.quantity or 0 + def quantity_total(node, seen=None): + seen = seen or set() + if node.id in seen: + return 0 + seen.add(node.id) + children = list(node.children) + if not children: + return node.quantity or 1 + return sum(quantity_total(child, seen) for child in children if not child.is_deleted) + parent.individual_count = quantity_total(parent) categories = EquipmentCategory.query.order_by(EquipmentCategory.name).all() buildings = Building.query.order_by(Building.name).all() diff --git a/app_new/templates/equipments/index.html b/app_new/templates/equipments/index.html index 9c2c1f5..95cb9c7 100644 --- a/app_new/templates/equipments/index.html +++ b/app_new/templates/equipments/index.html @@ -61,7 +61,7 @@ {% if view == 'zones' %}
| {{ item.name }} | {{ item.category }} | {{ item.quantity }} |
| {{ item.name }} | {{ item.category }} | {{ item.quantity }} |