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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amer
erp5
Commits
53646336
Commit
53646336
authored
Apr 28, 2015
by
wenjie.zheng
Committed by
Sebastien Robin
Jul 16, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow.py: modify workflow getter since workflow_module has been merged with portal_workflow.
parent
56b8bc8b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
25 deletions
+21
-25
product/ERP5/Tool/ERP5WorkflowTool.py
product/ERP5/Tool/ERP5WorkflowTool.py
+21
-25
No files found.
product/ERP5/Tool/ERP5WorkflowTool.py
View file @
53646336
...
@@ -185,7 +185,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -185,7 +185,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
case
=
1
case
=
1
break
break
for
workflow_id
in
workflow_list
:
for
workflow_id
in
workflow_list
:
wf
=
self
.
getPortalObject
().
getDefaultModule
(
'Workflow'
)
.
_getOb
(
workflow_id
)
### _getObjectByRef
wf
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
workflow_id
)
### _getObjectByRef
if
wf
.
isActionSupported
(
ob
,
action
,
**
kw
):
if
wf
.
isActionSupported
(
ob
,
action
,
**
kw
):
found
=
1
found
=
1
case
=
2
case
=
2
...
@@ -198,7 +198,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -198,7 +198,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
if
case
==
1
:
if
case
==
1
:
wf
=
self
.
getWorkflowById
(
wf_id
)
wf
=
self
.
getWorkflowById
(
wf_id
)
else
:
else
:
wf
=
self
.
getPortalObject
().
getDefaultModule
(
'Workflow'
)
.
_getOb
(
wf_id
,
None
)
### _getObjectByRef
wf
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
wf_id
,
None
)
### _getObjectByRef
if
wf
is
None
:
if
wf
is
None
:
raise
WorkflowException
(
_
(
u'Requested workflow definition not found.'
))
raise
WorkflowException
(
_
(
u'Requested workflow definition not found.'
))
...
@@ -227,7 +227,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -227,7 +227,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
case
=
1
case
=
1
break
break
for
workflow_id
in
workflow_list
:
for
workflow_id
in
workflow_list
:
workflow
=
self
.
getPortalObject
().
getDefaultModule
(
'Workflow'
)
.
_getOb
(
workflow_id
)
### _getObjectByRef
workflow
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
workflow_id
)
### _getObjectByRef
if
workflow
.
isInfoSuported
(
ob
,
name
):
if
workflow
.
isInfoSuported
(
ob
,
name
):
found
=
1
found
=
1
case
=
2
case
=
2
...
@@ -243,7 +243,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -243,7 +243,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
if
case
==
1
:
if
case
==
1
:
wf
=
self
.
getWorkflowById
(
wf_id
)
wf
=
self
.
getWorkflowById
(
wf_id
)
else
:
else
:
wf
=
self
.
getPortalObject
().
getDefaultModule
(
'Workflow'
)
.
_getOb
(
wf_id
)
### _getObjectByRef
wf
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
wf_id
)
### _getObjectByRef
if
wf
is
None
:
if
wf
is
None
:
if
default
is
_marker
:
if
default
is
_marker
:
raise
WorkflowException
(
raise
WorkflowException
(
...
@@ -262,8 +262,8 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -262,8 +262,8 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
"""
"""
temp_workflow_list
=
[]
temp_workflow_list
=
[]
temp_workflow_id_list
=
[]
temp_workflow_id_list
=
[]
for
dc_workflow_id
in
self
.
getPortalObject
().
portal_
erp5
workflow
:
for
dc_workflow_id
in
self
.
getPortalObject
().
portal_workflow
:
dc_workflow
=
self
.
getPortalObject
().
portal_
erp5
workflow
.
get
(
dc_workflow_id
)
dc_workflow
=
self
.
getPortalObject
().
portal_workflow
.
get
(
dc_workflow_id
)
workflow_type
=
dc_workflow
.
__class__
.
__name__
workflow_type
=
dc_workflow
.
__class__
.
__name__
if
workflow_type
==
'Workflow'
or
workflow_type
==
'Interaction Workflow'
:
if
workflow_type
==
'Workflow'
or
workflow_type
==
'Interaction Workflow'
:
continue
continue
...
@@ -273,18 +273,14 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -273,18 +273,14 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
temp_workflow_id_list
.
append
(
temp_workflow
.
getTitle
())
temp_workflow_id_list
.
append
(
temp_workflow
.
getTitle
())
return
temp_workflow_list
return
temp_workflow_list
def
migrateWorkflow
(
self
,
workflow_id
):
""" Launch manually the migration of DCWorkflow.
"""
pass
def
getWorkflowValueListFor
(
self
,
portal_type
):
def
getWorkflowValueListFor
(
self
,
portal_type
):
""" Return a list of workflows bound to selected portal_type.
""" Return a list of workflows bound to selected portal_type.
Caution: this method will convert DC workflow.
"""
"""
workflow_list
=
[]
workflow_list
=
[]
if
portal_type
is
None
:
if
portal_type
is
None
:
return
workflow_list
return
workflow_list
workflow_module
=
self
.
getPortalObject
().
getDefaultModule
(
'Workflow'
)
workflow_module
=
self
.
getPortalObject
().
portal_workflow
for
workflow_id
in
portal_type
.
getTypeERP5WorkflowList
():
for
workflow_id
in
portal_type
.
getTypeERP5WorkflowList
():
workflow_list
.
append
(
workflow_module
.
_getOb
(
workflow_id
))
### _getObjectByRef
workflow_list
.
append
(
workflow_module
.
_getOb
(
workflow_id
))
### _getObjectByRef
...
@@ -293,12 +289,10 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -293,12 +289,10 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
if
dc_workflow_list
is
None
:
if
dc_workflow_list
is
None
:
return
workflow_list
return
workflow_list
temporary_conversion
=
1
for
dc_workflow_id
in
dc_workflow_list
:
for
dc_workflow_id
in
dc_workflow_list
:
duplicated_wf
=
0
duplicated_wf
=
0
for
wf
in
workflow_module
.
objectValues
():
for
wf
in
workflow_module
.
objectValues
():
if
dc_workflow_id
==
wf
.
get
Ref
()
or
dc_workflow_id
==
wf
.
getTitle
():
if
dc_workflow_id
==
wf
.
get
Id
():
duplicated_wf
=
1
duplicated_wf
=
1
if
getattr
(
workflow_module
,
dc_workflow_id
,
None
)
is
not
None
:
if
getattr
(
workflow_module
,
dc_workflow_id
,
None
)
is
not
None
:
duplicated_wf
=
1
duplicated_wf
=
1
...
@@ -307,8 +301,10 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -307,8 +301,10 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
continue
continue
dc_workflow
=
self
.
getWorkflowById
(
dc_workflow_id
)
dc_workflow
=
self
.
getWorkflowById
(
dc_workflow_id
)
workflow
=
self
.
dc_workflow_asERP5Object
(
workflow_module
,
dc_workflow
,
temporary_conversion
)
#temporary_conversion = 1
workflow_list
.
extend
(
workflow
)
#workflow = self.dc_workflow_asERP5Object(workflow_module, dc_workflow, temporary_conversion)
#workflow_list.extend(workflow)
workflow_list
.
extend
(
dc_workflow
)
return
workflow_list
return
workflow_list
def
dc_workflow_asERP5Object
(
self
,
container
,
dc_workflow
,
temp
):
def
dc_workflow_asERP5Object
(
self
,
container
,
dc_workflow
,
temp
):
...
@@ -325,7 +321,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -325,7 +321,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
workflow
=
container
.
newContent
(
portal_type
=
'Interaction Workflow'
,
temp_object
=
temp
)
workflow
=
container
.
newContent
(
portal_type
=
'Interaction Workflow'
,
temp_object
=
temp
)
workflow
.
setManagerBypass
(
dc_workflow
.
manager_bypass
)
workflow
.
setManagerBypass
(
dc_workflow
.
manager_bypass
)
workflow
.
setId
(
dc_workflow
.
id
)
workflow
.
setId
(
dc_workflow
.
id
+
'_converted'
)
workflow
.
edit
(
title
=
dc_workflow
.
title
)
workflow
.
edit
(
title
=
dc_workflow
.
title
)
workflow
.
edit
(
description
=
dc_workflow
.
description
)
workflow
.
edit
(
description
=
dc_workflow
.
description
)
...
@@ -336,7 +332,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -336,7 +332,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
LOG
(
"2.1 Convert transition '%s' of workflow '%s'"
%
(
tdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
LOG
(
"2.1 Convert transition '%s' of workflow '%s'"
%
(
tdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
transition
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
temp_object
=
temp
)
transition
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
temp_object
=
temp
)
transition
.
edit
(
title
=
tdef
.
title
)
transition
.
edit
(
title
=
tdef
.
title
)
transition
.
setId
(
tdef
.
id
)
transition
.
setId
(
tdef
.
id
+
'_transition'
)
transition
.
setTriggerType
(
tdef
.
trigger_type
)
transition
.
setTriggerType
(
tdef
.
trigger_type
)
transition
.
setActboxCategory
(
tdef
.
actbox_category
)
transition
.
setActboxCategory
(
tdef
.
actbox_category
)
transition
.
setActboxIcon
(
tdef
.
actbox_icon
)
transition
.
setActboxIcon
(
tdef
.
actbox_icon
)
...
@@ -352,7 +348,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -352,7 +348,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
LOG
(
"2.2 Convert state '%s' of workflow '%s'"
%
(
sdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
LOG
(
"2.2 Convert state '%s' of workflow '%s'"
%
(
sdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
state
=
workflow
.
newContent
(
portal_type
=
'State'
,
temp_object
=
temp
)
state
=
workflow
.
newContent
(
portal_type
=
'State'
,
temp_object
=
temp
)
state
.
edit
(
title
=
sdef
.
title
)
state
.
edit
(
title
=
sdef
.
title
)
state
.
setId
(
sdef
.
id
)
state
.
setId
(
sdef
.
id
+
'_state'
)
state
.
setStatePermissionRoles
(
sdef
.
permission_roles
)
state
.
setStatePermissionRoles
(
sdef
.
permission_roles
)
state
.
setDestinationList
(
sdef
.
transitions
)
state
.
setDestinationList
(
sdef
.
transitions
)
### create worklists (portal_type = Worklist)
### create worklists (portal_type = Worklist)
...
@@ -361,7 +357,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -361,7 +357,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
LOG
(
"2.3 Convert worklist '%s' of workflow '%s'"
%
(
qdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
LOG
(
"2.3 Convert worklist '%s' of workflow '%s'"
%
(
qdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
worklist
=
workflow
.
newContent
(
portal_type
=
'Worklist'
,
temp_object
=
temp
)
worklist
=
workflow
.
newContent
(
portal_type
=
'Worklist'
,
temp_object
=
temp
)
worklist
.
edit
(
title
=
qdef
.
title
)
worklist
.
edit
(
title
=
qdef
.
title
)
worklist
.
setId
(
qdef
.
id
)
worklist
.
setId
(
qdef
.
id
+
'_worklist'
)
for
key
,
values
in
qdef
.
var_matches
.
items
():
for
key
,
values
in
qdef
.
var_matches
.
items
():
if
key
==
'portal_type'
:
if
key
==
'portal_type'
:
worklist
.
setMatchedPortalTypeList
(
values
)
worklist
.
setMatchedPortalTypeList
(
values
)
...
@@ -380,7 +376,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -380,7 +376,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
tdef
=
dc_workflow
.
interactions
.
get
(
tid
)
tdef
=
dc_workflow
.
interactions
.
get
(
tid
)
LOG
(
"2.4 Convert interaction '%s' of workflow '%s'"
%
(
tdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
LOG
(
"2.4 Convert interaction '%s' of workflow '%s'"
%
(
tdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
interaction
.
edit
(
title
=
tdef
.
title
)
interaction
.
edit
(
title
=
tdef
.
title
)
interaction
.
setId
(
tdef
.
id
)
interaction
.
setId
(
tdef
.
id
+
'_interaction'
)
interaction
.
setActivateScriptName
(
tdef
.
activate_script_name
)
interaction
.
setActivateScriptName
(
tdef
.
activate_script_name
)
interaction
.
setAfterScriptName
(
tdef
.
after_script_name
)
interaction
.
setAfterScriptName
(
tdef
.
after_script_name
)
interaction
.
setBeforeCommitScriptName
(
tdef
.
before_commit_script_name
)
interaction
.
setBeforeCommitScriptName
(
tdef
.
before_commit_script_name
)
...
@@ -411,7 +407,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -411,7 +407,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
variable
=
workflow
.
newContent
(
portal_type
=
'Variable'
,
temp_object
=
temp
)
variable
=
workflow
.
newContent
(
portal_type
=
'Variable'
,
temp_object
=
temp
)
LOG
(
"2.6 Convert variable '%s' of workflow '%s'"
%
(
vdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
LOG
(
"2.6 Convert variable '%s' of workflow '%s'"
%
(
vdef
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in ERP5WorkflowTool.py'
)
variable
.
edit
(
title
=
vdef
.
title
)
variable
.
edit
(
title
=
vdef
.
title
)
variable
.
setId
(
vdef
.
id
)
variable
.
setId
(
vdef
.
id
+
'_variable'
)
variable
.
setAutomaticUpdate
(
vdef
.
update_always
)
variable
.
setAutomaticUpdate
(
vdef
.
update_always
)
variable
.
setDefaultExpr
(
vdef
.
default_expr
)
variable
.
setDefaultExpr
(
vdef
.
default_expr
)
variable
.
info_guard
=
vdef
.
info_guard
variable
.
info_guard
=
vdef
.
info_guard
...
@@ -451,7 +447,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -451,7 +447,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
if
state
and
transition_id
in
state
.
transitions
:
if
state
and
transition_id
in
state
.
transitions
:
return
1
return
1
for
workflow_id
in
ob
.
getTypeInfo
().
getTypeERP5WorkflowList
():
for
workflow_id
in
ob
.
getTypeInfo
().
getTypeERP5WorkflowList
():
workflow
=
self
.
getPortalObject
().
getDefaultModule
(
'Workflow'
)
.
_getOb
(
workflow_id
)
### _getObjectByRef
workflow
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
workflow_id
)
### _getObjectByRef
state
=
workflow
.
_getWorkflowStateOf
(
ob
)
state
=
workflow
.
_getWorkflowStateOf
(
ob
)
if
state
and
transition_id
in
state
.
getDestinationIdList
():
if
state
and
transition_id
in
state
.
getDestinationIdList
():
return
1
return
1
...
@@ -616,7 +612,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
...
@@ -616,7 +612,7 @@ class ERP5WorkflowTool(BaseTool, original_WorkflowTool):
if
(
workflow_list
is
not
None
)
and
(
workflow_list
is
not
[]):
if
(
workflow_list
is
not
None
)
and
(
workflow_list
is
not
[]):
for
wf_id
in
workflow_list
:
for
wf_id
in
workflow_list
:
did
[
wf_id
]
=
None
did
[
wf_id
]
=
None
wf
=
self
.
getPortalObject
().
getDefaultModule
(
'Workflow'
)
.
_getOb
(
wf_id
,
None
)
### getObjectByRef
wf
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
wf_id
,
None
)
### getObjectByRef
if
wf
is
None
:
if
wf
is
None
:
raise
NotImplementedError
(
"Can not find workflow: %s, please check if the workflow exists."
%
wf_id
)
raise
NotImplementedError
(
"Can not find workflow: %s, please check if the workflow exists."
%
wf_id
)
a
=
wf
.
listObjectActions
(
info
)
a
=
wf
.
listObjectActions
(
info
)
...
...
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