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
iv
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
Show 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):
...
@@ -822,6 +822,8 @@ def DCWorkflowDefinition_getTransitionValueList(self):
return
self
.
transitions
.
values
()
return
self
.
transitions
.
values
()
else
:
else
:
return
[]
return
[]
def
DCWorkflowDefinition_getTransitionIdByReference
(
self
,
reference
):
return
reference
def
DCWorkflowDefinition_getTransitionIdList
(
self
):
def
DCWorkflowDefinition_getTransitionIdList
(
self
):
if
self
.
transitions
is
not
None
:
if
self
.
transitions
is
not
None
:
return
self
.
transitions
.
objectIds
()
return
self
.
transitions
.
objectIds
()
...
@@ -840,6 +842,8 @@ def DCWorkflowDefinition_getWorklistIdList(self):
...
@@ -840,6 +842,8 @@ def DCWorkflowDefinition_getWorklistIdList(self):
return
[]
return
[]
def
DCWorkflowDefinition_propertyIds
(
self
):
def
DCWorkflowDefinition_propertyIds
(
self
):
return
sorted
(
self
.
__dict__
.
keys
())
return
sorted
(
self
.
__dict__
.
keys
())
def
DCWorkflowDefinition_getScriptIdByReference
(
self
,
reference
):
return
reference
def
DCWorkflowDefinition_getScriptValueList
(
self
):
def
DCWorkflowDefinition_getScriptValueList
(
self
):
if
self
.
scripts
is
not
None
:
if
self
.
scripts
is
not
None
:
return
self
.
scripts
.
values
()
return
self
.
scripts
.
values
()
...
@@ -1122,6 +1126,8 @@ DCWorkflowDefinition.showDict = DCWorkflowDefinition_showDict
...
@@ -1122,6 +1126,8 @@ DCWorkflowDefinition.showDict = DCWorkflowDefinition_showDict
DCWorkflowDefinition
.
propertyIds
=
DCWorkflowDefinition_propertyIds
DCWorkflowDefinition
.
propertyIds
=
DCWorkflowDefinition_propertyIds
DCWorkflowDefinition
.
getStateVariable
=
DCWorkflowDefinition_getStateVariable
DCWorkflowDefinition
.
getStateVariable
=
DCWorkflowDefinition_getStateVariable
DCWorkflowDefinition
.
getPortalType
=
DCWorkflowDefinition_getPortalType
DCWorkflowDefinition
.
getPortalType
=
DCWorkflowDefinition_getPortalType
DCWorkflowDefinition
.
getScriptIdByReference
=
DCWorkflowDefinition_getScriptIdByReference
DCWorkflowDefinition
.
getTransitionIdByReference
=
DCWorkflowDefinition_getTransitionIdByReference
StateDefinition
.
getReference
=
method_getReference
StateDefinition
.
getReference
=
method_getReference
StateDefinition
.
getDestinationIdList
=
StateDefinition_getDestinationIdList
StateDefinition
.
getDestinationIdList
=
StateDefinition_getDestinationIdList
StateDefinition
.
getDestinationReferenceList
=
StateDefinition_getDestinationIdList
StateDefinition
.
getDestinationReferenceList
=
StateDefinition_getDestinationIdList
...
...
product/ERP5Workflow/Document/Workflow.py
View file @
4a3f3be4
...
@@ -549,6 +549,12 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
...
@@ -549,6 +549,12 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
return
[
worklist
.
getReference
()
return
[
worklist
.
getReference
()
for
worklist
in
self
.
objectValues
(
portal_type
=
"Worklist"
)]
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
):
def
getWorklistValueById
(
self
,
worklist_reference
):
return
self
.
_getOb
(
'worklist_'
+
worklist_reference
,
None
)
return
self
.
_getOb
(
'worklist_'
+
worklist_reference
,
None
)
...
...
product/ERP5Workflow/Tool/WorkflowTool.py
View file @
4a3f3be4
...
@@ -199,7 +199,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -199,7 +199,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
found
=
0
found
=
0
for
workflow
in
workflow_list
:
for
workflow
in
workflow_list
:
if
workflow
.
getPortalType
()
==
'Workflow'
:
if
workflow
.
getPortalType
()
==
'Workflow'
:
action_id
=
'transition_'
+
action_reference
action_id
=
workflow
.
getTransitionIdByReference
(
action_reference
)
if
workflow
.
isActionSupported
(
current_object
,
action_id
,
**
kw
):
if
workflow
.
isActionSupported
(
current_object
,
action_id
,
**
kw
):
found
=
1
found
=
1
break
break
...
@@ -211,7 +211,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -211,7 +211,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if
workflow
is
None
:
if
workflow
is
None
:
raise
WorkflowException
(
_
(
u'Requested workflow definition not found.'
))
raise
WorkflowException
(
_
(
u'Requested workflow definition not found.'
))
if
workflow
.
getPortalType
()
==
'Workflow'
:
if
workflow
.
getPortalType
()
==
'Workflow'
:
action_id
=
'transition_'
+
action_reference
action_id
=
workflow
.
getTransitionIdByReference
(
action_reference
)
result
=
self
.
_invokeWithNotification
(
result
=
self
.
_invokeWithNotification
(
workflow_list
,
current_object
,
action_id
,
workflow
.
doActionFor
,
workflow_list
,
current_object
,
action_id
,
workflow
.
doActionFor
,
(
current_object
,
action_id
)
+
args
,
kw
)
(
current_object
,
action_id
)
+
args
,
kw
)
...
@@ -290,8 +290,8 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -290,8 +290,8 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
initial_script_name_list
=
[
initial_script_name_list
]
initial_script_name_list
=
[
initial_script_name_list
]
for
script_name
in
initial_script_name_list
:
for
script_name
in
initial_script_name_list
:
if
script_name
:
if
script_name
:
script
=
getattr
(
workflow
,
'script_'
+
script_name
,
None
)
or
\
script
=
getattr
(
workflow
,
workflow
.
getScriptIdByReference
(
script_name
)
,
None
)
or
\
getattr
(
workflow
,
'transition_'
+
script_name
,
None
)
getattr
(
workflow
,
workflow
.
getTransitionIdByReference
(
script_name
)
,
None
)
script_path
=
script
.
getRelativeUrl
()
script_path
=
script
.
getRelativeUrl
()
script_path_list
.
append
(
script_path
)
script_path_list
.
append
(
script_path
)
return
script_path_list
return
script_path_list
...
@@ -333,7 +333,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -333,7 +333,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
for
script_id
in
dc_workflow_script_list
:
for
script_id
in
dc_workflow_script_list
:
script
=
dc_workflow_script_list
.
get
(
script_id
)
script
=
dc_workflow_script_list
.
get
(
script_id
)
# add a prefix if there is a script & method conflict
# 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'
,
portal_type
=
'Workflow Script'
,
temp_object
=
is_temporary
)
temp_object
=
is_temporary
)
workflow_script
.
setTitle
(
script
.
title
)
workflow_script
.
setTitle
(
script
.
title
)
...
@@ -428,7 +428,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -428,7 +428,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
sdef
.
addPossibleTransition
(
transition_id
)
sdef
.
addPossibleTransition
(
transition_id
)
# set transition's destination state:
# set transition's destination state:
for
tid
in
dc_workflow_transition_value_list
:
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
)
state
=
getattr
(
workflow
,
'state_'
+
dc_workflow_transition_value_list
.
get
(
tid
).
new_state_id
,
None
)
if
state
is
None
:
if
state
is
None
:
# it's a remain in state transition.
# it's a remain in state transition.
...
@@ -563,7 +563,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -563,7 +563,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
dc_workflow_transition_value_list
=
dc_workflow
.
transitions
dc_workflow_transition_value_list
=
dc_workflow
.
transitions
for
tid
in
dc_workflow_transition_value_list
:
for
tid
in
dc_workflow_transition_value_list
:
origin_tdef
=
dc_workflow_transition_value_list
[
tid
]
origin_tdef
=
dc_workflow_transition_value_list
[
tid
]
transition
=
workflow
.
_getOb
(
'transition_'
+
tid
)
transition
=
workflow
.
getTransitionValueById
(
tid
)
new_category
=
[]
new_category
=
[]
if
origin_tdef
.
var_exprs
is
None
:
if
origin_tdef
.
var_exprs
is
None
:
var_exprs
=
{}
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