diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py index 31d101ad2bb53a808e464fc95fb86bd12a759dab..95a543fb7850ba0002b30d88f72dabca3cb66311 100644 --- a/product/ERP5/Document/BusinessTemplate.py +++ b/product/ERP5/Document/BusinessTemplate.py @@ -894,6 +894,15 @@ class ObjectTemplateItem(BaseTemplateItem): # because they change when we add subobjects groups[path] = deepcopy(obj.groups) # copy the object + if (getattr(aq_base(obj), '_mt_index', None) is not None and + obj._count() == 0): + # some btrees were exported in a corrupted state. They're empty but + # their metadata-index (._mt_index) contains entries which in + # Zope 2.12 are used for .objectIds(), .objectValues() and + # .objectItems(). In these cases, force the + LOG('Products.ERP5.Document.BusinessTemplate', WARNING, + 'Cleaning corrupt BTreeFolder2 object at %r.' % (path,)) + obj._initBTrees() obj = obj._getCopy(container) try: container._setObject(object_id, obj)