Commit a6e5d03d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Vincent Pelletier

patches/DCWorkflow: use 'user/getIdOrUserName' as workflow actor expression...

patches/DCWorkflow: use 'user/getIdOrUserName' as workflow actor expression instead of 'user/getUserName'.

so that ID is used for ERP5 user case, that should never change, and User Name is used for system users
like Anonymous User or System Processes, without changing all workflow definitions.
parent 71737403
...@@ -363,6 +363,11 @@ DCWorkflow.ValidationFailed = ValidationFailed ...@@ -363,6 +363,11 @@ DCWorkflow.ValidationFailed = ValidationFailed
ModuleSecurityInfo('Products.DCWorkflow.DCWorkflow').declarePublic('ValidationFailed') ModuleSecurityInfo('Products.DCWorkflow.DCWorkflow').declarePublic('ValidationFailed')
from Products.CMFCore.Expression import getEngine
userGetIdOrUserNameExpression = Expression('user/getIdOrUserName')
userGetIdOrUserNameExpression._v_compiled = getEngine().compile(
userGetIdOrUserNameExpression.text)
# Patch excecuteTransition from DCWorkflowDefinition, to put ValidationFailed # Patch excecuteTransition from DCWorkflowDefinition, to put ValidationFailed
# error messages in workflow history. # error messages in workflow history.
...@@ -432,6 +437,12 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None): ...@@ -432,6 +437,12 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None):
value = former_status[id] value = former_status[id]
else: else:
if vdef.default_expr is not None: if vdef.default_expr is not None:
# PATCH : if Default expression for 'actor' is 'user/getUserName',
# we use 'user/getIdOrUserName' instead to store user ID for ERP5
# user.
if id == 'actor' and vdef.default_expr.text == 'user/getUserName':
expr = userGetIdOrUserNameExpression
else:
expr = vdef.default_expr expr = vdef.default_expr
else: else:
value = vdef.default_value value = vdef.default_value
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment