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
Alain Takoudjou
erp5
Commits
3d838a2c
Commit
3d838a2c
authored
May 06, 2015
by
wenjie.zheng
Committed by
Sebastien Robin
Jul 16, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5WorkflowTool.py: deploy universal methods; clean codes.
parent
7963c390
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
55 deletions
+25
-55
product/ERP5/Tool/ERP5WorkflowTool.py
product/ERP5/Tool/ERP5WorkflowTool.py
+25
-55
No files found.
product/ERP5/Tool/ERP5WorkflowTool.py
View file @
3d838a2c
...
...
@@ -134,14 +134,16 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool):
any state to another in same workflow)
"""
from
Products.ERP5.InteractionWorkflow
import
InteractionWorkflowDefinition
workflow_list
=
self
.
getWorkflowsFor
(
ob
)
from
Products.ERP5Workflow.Document.InteractionWorkflow
import
InteractionWorkflow
workflow_list
=
self
.
getWorkflowValueListFor
(
ob
.
getPortalType
())
if
wf_id
is
None
:
if
not
workflow_list
:
raise
WorkflowException
(
'No workflows found.'
)
found
=
False
for
workflow
in
workflow_list
:
if
not
isinstance
(
workflow
,
InteractionWorkflowDefinition
)
and
\
state_id
in
workflow
.
states
.
_mapping
:
if
not
isinstance
(
workflow
,
InteractionWorkflowDefinition
)
or
\
not
isinstance
(
workflow
,
InteractionWorkflow
):
if
state_id
in
workflow
.
states
.
_mapping
:
found
=
True
break
if
not
found
:
...
...
@@ -159,32 +161,21 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool):
in at least one associated workflow
"""
from
Products.ERP5.InteractionWorkflow
import
InteractionWorkflowDefinition
for
workflow
in
(
wf_id
and
(
self
[
wf_id
],)
or
self
.
getWorkflowsFor
(
ob
)):
if
not
isinstance
(
workflow
,
InteractionWorkflowDefinition
)
and
\
state_id
in
workflow
.
states
.
_mapping
:
from
Products.ERP5Workflow.Document.InteractionWorkflow
import
InteractionWorkflow
for
workflow
in
(
wf_id
and
(
self
[
wf_id
],)
or
self
.
getWorkflowValueListFor
(
ob
.
getPortalType
())):
if
not
isinstance
(
workflow
,
InteractionWorkflowDefinition
)
or
\
not
isinstance
(
workflow
,
InteractionWorkflow
):
if
state_id
in
workflow
.
states
.
_mapping
:
return
True
return
False
def
doActionFor
(
self
,
ob
,
action
,
wf_id
=
None
,
*
args
,
**
kw
):
wfs
=
self
.
getWorkflowsFor
(
ob
)
# dc workflow
workflow_list
=
ob
.
getTypeInfo
().
getTypeERP5WorkflowList
()
# workflow
case
=
1
LOG
(
" 173 do action '%s' for object '%s'"
%
(
action
,
ob
.
getId
()),
WARNING
,
" in ERP5 Workflow Tool.py"
)
if
wfs
is
None
or
wf_id
in
workflow_list
:
wfs
=
()
case
=
2
workflow_list
=
self
.
getWorkflowValueListFor
(
ob
.
getPortalType
())
if
wf_id
is
None
:
if
w
fs
==
()
and
w
orkflow_list
==
[]:
if
workflow_list
==
[]:
raise
WorkflowException
(
_
(
u'No workflows found.'
))
found
=
0
for
wf
in
wfs
:
if
wf
.
isActionSupported
(
ob
,
action
,
**
kw
):
found
=
1
case
=
1
break
for
workflow_id
in
workflow_list
:
wf
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
workflow_id
)
for
wf
in
workflow_list
:
if
wf
.
isActionSupported
(
ob
,
action
,
**
kw
):
found
=
1
case
=
2
...
...
@@ -192,41 +183,23 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool):
if
not
found
:
msg
=
_
(
u"No workflow provides the '${action_id}' action."
,
mapping
=
{
'action_id'
:
action
})
raise
WorkflowException
(
msg
)
else
:
if
case
==
1
:
wf
=
self
.
getWorkflowById
(
wf_id
)
else
:
wf
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
wf_id
,
None
)
if
wf
is
None
:
raise
WorkflowException
(
_
(
u'Requested workflow definition not found.'
))
if
case
==
1
:
return
self
.
_invokeWithNotification
(
wfs
,
ob
,
action
,
wf
.
doActionFor
,
(
ob
,
action
)
+
args
,
kw
)
else
:
return
wf
.
doActionFor
(
ob
,
action
)
return
self
.
_invokeWithNotification
(
workflow_list
,
ob
,
action
,
wf
.
doActionFor
,
(
ob
,
action
)
+
args
,
kw
)
def
_getInfoFor
(
self
,
ob
,
name
,
default
=
_marker
,
wf_id
=
None
,
*
args
,
**
kw
):
wfs
=
self
.
getWorkflowsFor
(
ob
)
workflow_list
=
ob
.
getTypeInfo
().
getTypeERP5WorkflowList
()
case
=
1
if
wfs
is
None
or
wf_id
in
workflow_list
:
case
=
2
workflow_list
=
self
.
getWorkflowValueListFor
(
ob
.
getPortalType
())
if
wf_id
is
None
:
if
w
fs
is
None
and
w
orkflow_list
==
[]:
if
workflow_list
==
[]:
if
default
is
_marker
:
raise
WorkflowException
(
_
(
u'No workflows found.'
))
else
:
return
default
found
=
0
for
wf
in
wfs
:
if
wf
.
isInfoSupported
(
ob
,
name
):
found
=
1
case
=
1
break
for
workflow_id
in
workflow_list
:
workflow
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
workflow_id
)
for
workflow
in
workflow_list
:
if
workflow
.
isInfoSuported
(
ob
,
name
):
found
=
1
case
=
2
...
...
@@ -239,10 +212,7 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool):
else
:
return
default
else
:
if
case
==
1
:
wf
=
self
.
getWorkflowById
(
wf_id
)
else
:
wf
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
wf_id
)
if
wf
is
None
:
if
default
is
_marker
:
raise
WorkflowException
(
...
...
@@ -423,12 +393,12 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool):
def
isTransitionPossible
(
self
,
ob
,
transition_id
,
wf_id
=
None
):
"""Test if the given transition exist from the current state.
"""
for
workflow
in
(
wf_id
and
(
self
[
wf_id
],)
or
self
.
getWorkflow
sFor
(
ob
)):
for
workflow
in
(
wf_id
and
(
self
[
wf_id
],)
or
self
.
getWorkflow
ValueListFor
(
ob
.
getPortalType
()
)):
state
=
workflow
.
_getWorkflowStateOf
(
ob
)
if
state
and
transition_id
in
state
.
transitions
:
return
1
for
workflow_id
in
ob
.
getTypeInfo
().
getTypeERP5WorkflowList
():
workflow
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
workflow_id
)
### _getObjectByRef
workflow
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
workflow_id
)
state
=
workflow
.
_getWorkflowStateOf
(
ob
)
if
state
and
transition_id
in
state
.
getDestinationIdList
():
return
1
...
...
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