Skip to content

ActivityTool: Add explicit portal type in `newContent`

The newContent call in getMessageTempObjectList has no explicit portal_type parameter. This used to work well when there was only one allowed portal type. However, in one of our customer projects a new portal type was added. Thus, newContent can pick this portal type instead, causing the following exception (because the new portal type happens to have a delete transition in its workflow):

[...]
  Module Products.ERP5Form.Selection, line 240, in __call__
    result = method(**kw)
  Module Products.ERP5Type.patches.PythonScript, line 179, in __call__
    return self._orig_bindAndExec(args, kw, None)
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
    return self._exec(bound_data, args, kw)
  Module Products.PythonScripts.PythonScript, line 344, in _exec
    result = f(*args, **kw)
  Module script, line 21, in ActivityTool_getMessageList
   - <PythonScript at /erp5/ActivityTool_getMessageList used for /erp5/portal_activities>
   - Line 21
    message.edit(delete = '[Delete]')
  Module Products.ERP5Type.mixin.temporary, line 89, in edit
    return super(TemporaryDocumentMixin, self).edit(*args, **kw)
  Module Products.ERP5Type.Base, line 195, in __call__
    return self.__dict__['_m'](instance, *args, **kw)
  Module Products.ERP5Type.Base, line 1510, in edit
    reindex_object=reindex_object, restricted=1, **kw)
  Module Products.ERP5Type.Base, line 1477, in _edit
    unmodified_key_list = setChangedPropertyList(unordered_key_list)
  Module Products.ERP5Type.Base, line 1463, in setChangedPropertyList
    modified_object_list = _setProperty(key, kw[key])
  Module Products.ERP5Type.Base, line 1293, in _setProperty
    ERP5PropertyManager._setProperty(self, key, value, type=type)
  Module Products.ERP5Type.patches.PropertyManager, line 113, in PropertyManager_setProperty
    raise BadRequest, 'Invalid or duplicate property id: %s' % id
BadRequest: Invalid or duplicate property id: delete

The fix is to explicitly set the portal type to "Active Process".

Merge request reports