From 20ccb385d847827798dc652770606cf6a2151c8b Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 9 Mar 2023 18:38:54 +0100 Subject: [PATCH] add lots in list of erasures actions --- ereuse_devicehub/resources/device/models.py | 6 ++++++ ereuse_devicehub/templates/inventory/erasure_list.html | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 8d2baec1..168c4371 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -676,6 +676,12 @@ class Device(Thing): return args def get_lots_for_template(self): + if self.binding: + return self.binding.device.get_lots_for_template() + + if not self.lots and hasattr(self, 'parent') and self.parent: + return self.parent.get_lots_for_template() + lots = [] for lot in self.lots: if lot.is_incoming: diff --git a/ereuse_devicehub/templates/inventory/erasure_list.html b/ereuse_devicehub/templates/inventory/erasure_list.html index 2f36de71..e2154c3e 100644 --- a/ereuse_devicehub/templates/inventory/erasure_list.html +++ b/ereuse_devicehub/templates/inventory/erasure_list.html @@ -187,9 +187,9 @@ {% endif %} {{ ac.device.serial_number.upper() }} {% endif %} - {% if ac.device.my_partner.lots | length > 0 %} + {% if ac.device.get_lots_for_template() | length > 0 %}
- {% for lot in ac.device.my_partner.get_lots_for_template() %} + {% for lot in ac.device.get_lots_for_template() %} {{ lot }} {% endfor %}