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
Laurent S
erp5
Commits
5a967a85
Commit
5a967a85
authored
Apr 20, 2016
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
workflow tool : add method to check if transition is possible
parent
9d99e267
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
+31
-2
product/ERP5Type/patches/WorkflowTool.py
product/ERP5Type/patches/WorkflowTool.py
+31
-2
No files found.
product/ERP5Type/patches/WorkflowTool.py
View file @
5a967a85
...
...
@@ -22,10 +22,12 @@ from types import StringTypes
from
AccessControl
import
ClassSecurityInfo
,
Unauthorized
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.CMFCore.WorkflowTool
import
WorkflowTool
from
Products.CMFCore.WorkflowCore
import
Object
Moved
,
Object
Deleted
from
Products.CMFCore.WorkflowCore
import
ObjectDeleted
from
Products.CMFCore.WorkflowCore
import
WorkflowException
from
Products.DCWorkflow.DCWorkflow
import
DCWorkflowDefinition
from
Products.DCWorkflow.Transitions
import
TRIGGER_WORKFLOW_METHOD
from
Products.DCWorkflow.utils
import
Message
as
_
from
Products.DCWorkflow.Transitions
import
TRIGGER_USER_ACTION
from
Products.CMFCore.utils
import
getToolByName
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
,
AutoQuery
,
ComplexQuery
,
NegatedQuery
...
...
@@ -36,7 +38,6 @@ from sets import ImmutableSet
from
Acquisition
import
aq_base
from
Persistence
import
Persistent
from
Products.ERP5Type.Globals
import
PersistentMapping
from
itertools
import
izip
from
MySQLdb
import
ProgrammingError
,
OperationalError
from
DateTime
import
DateTime
...
...
@@ -947,4 +948,32 @@ def _isJumpToStatePossibleFor(self, ob, state_id, wf_id=None):
WorkflowTool
.
_jumpToStateFor
=
_jumpToStateFor
WorkflowTool
.
_isJumpToStatePossibleFor
=
_isJumpToStatePossibleFor
security
.
declarePublic
(
'canDoActionFor'
)
def
canDoActionFor
(
self
,
ob
,
action
,
wf_id
=
None
,
guard_kw
=
{}):
""" Check we can perform the given workflow action on 'ob'.
"""
if
wf_id
is
None
:
workflow_list
=
self
.
getWorkflowsFor
(
ob
)
or
()
else
:
workflow
=
self
.
getWorkflowById
(
wf_id
)
if
workflow
:
workflow_list
=
(
workflow
,)
else
:
workflow_list
=
()
for
workflow
in
workflow_list
:
state_definition
=
workflow
.
_getWorkflowStateOf
(
ob
)
if
state_definition
is
not
None
:
if
action
in
state_definition
.
transitions
:
transition_definition
=
workflow
.
transitions
.
get
(
action
,
None
)
if
transition_definition
is
not
None
and
\
transition_definition
.
trigger_type
==
TRIGGER_USER_ACTION
:
return
workflow
.
_checkTransitionGuard
(
transition_definition
,
ob
,
**
guard_kw
)
raise
WorkflowException
(
_
(
u"No workflow provides the '${action_id}' action."
,
mapping
=
{
'action_id'
:
action
}))
WorkflowTool
.
canDoActionFor
=
canDoActionFor
InitializeClass
(
WorkflowTool
)
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