Fix is_archive_unit_ref predicate to avoid crash on creating a new reference
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 06 Jan 2017 12:02:49 +0100
changeset 2227 ac4a8c9b5e95
parent 2226 58b4ad23290e
child 2257 2d824356706d
Fix is_archive_unit_ref predicate to avoid crash on creating a new reference Closes #16688070
views/archiveunit.py
--- a/views/archiveunit.py	Fri Jan 06 14:17:43 2017 +0100
+++ b/views/archiveunit.py	Fri Jan 06 12:02:49 2017 +0100
@@ -60,6 +60,8 @@
         if entity.cw_etype == 'SEDAArchiveUnit':
             entity = entity.first_level_choice
         elif entity.cw_etype == 'SEDAArchiveUnitRefId':
+            if not entity.seda_archive_unit_ref_id_from:
+                return 0  # other kind of reference
             entity = entity.seda_archive_unit_ref_id_from[0]
             if entity.cw_etype != 'SEDAAltArchiveUnitArchiveUnitRefId':
                 return 0  # other kind of reference