Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastien Robin
erp5
Commits
4a3f3be4
Commit
4a3f3be4
authored
Oct 11, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: add method to get transition/script id by reference
in order to remove hardcoded 'transition_' or 'script_'
parent
bea4e3d4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
7 deletions
+19
-7
product/ERP5Type/patches/DCWorkflow.py
product/ERP5Type/patches/DCWorkflow.py
+6
-0
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+6
-0
product/ERP5Workflow/Tool/WorkflowTool.py
product/ERP5Workflow/Tool/WorkflowTool.py
+7
-7
No files found.
product/ERP5Type/patches/DCWorkflow.py
View file @
4a3f3be4
...
...
@@ -822,6 +822,8 @@ def DCWorkflowDefinition_getTransitionValueList(self):
return
self
.
transitions
.
values
()
else
:
return
[]
def
DCWorkflowDefinition_getTransitionIdByReference
(
self
,
reference
):
return
reference
def
DCWorkflowDefinition_getTransitionIdList
(
self
):
if
self
.
transitions
is
not
None
:
return
self
.
transitions
.
objectIds
()
...
...
@@ -840,6 +842,8 @@ def DCWorkflowDefinition_getWorklistIdList(self):
return
[]
def
DCWorkflowDefinition_propertyIds
(
self
):
return
sorted
(
self
.
__dict__
.
keys
())
def
DCWorkflowDefinition_getScriptIdByReference
(
self
,
reference
):
return
reference
def
DCWorkflowDefinition_getScriptValueList
(
self
):
if
self
.
scripts
is
not
None
:
return
self
.
scripts
.
values
()
...
...
@@ -1122,6 +1126,8 @@ DCWorkflowDefinition.showDict = DCWorkflowDefinition_showDict
DCWorkflowDefinition
.
propertyIds
=
DCWorkflowDefinition_propertyIds
DCWorkflowDefinition
.
getStateVariable
=
DCWorkflowDefinition_getStateVariable
DCWorkflowDefinition
.
getPortalType
=
DCWorkflowDefinition_getPortalType
DCWorkflowDefinition
.
getScriptIdByReference
=
DCWorkflowDefinition_getScriptIdByReference
DCWorkflowDefinition
.
getTransitionIdByReference
=
DCWorkflowDefinition_getTransitionIdByReference
StateDefinition
.
getReference
=
method_getReference
StateDefinition
.
getDestinationIdList
=
StateDefinition_getDestinationIdList
StateDefinition
.
getDestinationReferenceList
=
StateDefinition_getDestinationIdList
...
...
product/ERP5Workflow/Document/Workflow.py
View file @
4a3f3be4
...
...
@@ -549,6 +549,12 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
return
[
worklist
.
getReference
()
for
worklist
in
self
.
objectValues
(
portal_type
=
"Worklist"
)]
def
getTransitionIdByReference
(
self
,
transition_reference
):
return
'transition_'
+
transition_reference
def
getScriptIdByReference
(
self
,
script_reference
):
return
'script_'
+
script_reference
def
getWorklistValueById
(
self
,
worklist_reference
):
return
self
.
_getOb
(
'worklist_'
+
worklist_reference
,
None
)
...
...
product/ERP5Workflow/Tool/WorkflowTool.py
View file @
4a3f3be4
...
...
@@ -199,7 +199,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
found
=
0
for
workflow
in
workflow_list
:
if
workflow
.
getPortalType
()
==
'Workflow'
:
action_id
=
'transition_'
+
action_reference
action_id
=
workflow
.
getTransitionIdByReference
(
action_reference
)
if
workflow
.
isActionSupported
(
current_object
,
action_id
,
**
kw
):
found
=
1
break
...
...
@@ -211,7 +211,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if
workflow
is
None
:
raise
WorkflowException
(
_
(
u'Requested workflow definition not found.'
))
if
workflow
.
getPortalType
()
==
'Workflow'
:
action_id
=
'transition_'
+
action_reference
action_id
=
workflow
.
getTransitionIdByReference
(
action_reference
)
result
=
self
.
_invokeWithNotification
(
workflow_list
,
current_object
,
action_id
,
workflow
.
doActionFor
,
(
current_object
,
action_id
)
+
args
,
kw
)
...
...
@@ -290,8 +290,8 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
initial_script_name_list
=
[
initial_script_name_list
]
for
script_name
in
initial_script_name_list
:
if
script_name
:
script
=
getattr
(
workflow
,
'script_'
+
script_name
,
None
)
or
\
getattr
(
workflow
,
'transition_'
+
script_name
,
None
)
script
=
getattr
(
workflow
,
workflow
.
getScriptIdByReference
(
script_name
)
,
None
)
or
\
getattr
(
workflow
,
workflow
.
getTransitionIdByReference
(
script_name
)
,
None
)
script_path
=
script
.
getRelativeUrl
()
script_path_list
.
append
(
script_path
)
return
script_path_list
...
...
@@ -333,7 +333,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
for
script_id
in
dc_workflow_script_list
:
script
=
dc_workflow_script_list
.
get
(
script_id
)
# add a prefix if there is a script & method conflict
workflow_script
=
workflow
.
newContent
(
id
=
'script_'
+
script_id
,
workflow_script
=
workflow
.
newContent
(
id
=
workflow
.
getScriptIdByReference
(
script_id
)
,
portal_type
=
'Workflow Script'
,
temp_object
=
is_temporary
)
workflow_script
.
setTitle
(
script
.
title
)
...
...
@@ -428,7 +428,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
sdef
.
addPossibleTransition
(
transition_id
)
# set transition's destination state:
for
tid
in
dc_workflow_transition_value_list
:
tdef
=
workflow
.
_getOb
(
'transition_'
+
tid
)
tdef
=
workflow
.
getTransitionValueById
(
tid
)
state
=
getattr
(
workflow
,
'state_'
+
dc_workflow_transition_value_list
.
get
(
tid
).
new_state_id
,
None
)
if
state
is
None
:
# it's a remain in state transition.
...
...
@@ -563,7 +563,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
dc_workflow_transition_value_list
=
dc_workflow
.
transitions
for
tid
in
dc_workflow_transition_value_list
:
origin_tdef
=
dc_workflow_transition_value_list
[
tid
]
transition
=
workflow
.
_getOb
(
'transition_'
+
tid
)
transition
=
workflow
.
getTransitionValueById
(
tid
)
new_category
=
[]
if
origin_tdef
.
var_exprs
is
None
:
var_exprs
=
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment