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
amrani
erp5
Commits
d301f95d
Commit
d301f95d
authored
Mar 04, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: wip
parent
6c784645
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
22 deletions
+31
-22
product/ERP5/Document/PythonScript.py
product/ERP5/Document/PythonScript.py
+0
-8
product/ERP5Workflow/Document/Transition.py
product/ERP5Workflow/Document/Transition.py
+26
-12
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+1
-0
product/ERP5Workflow/Document/WorkflowScript.py
product/ERP5Workflow/Document/WorkflowScript.py
+4
-2
No files found.
product/ERP5/Document/PythonScript.py
View file @
d301f95d
...
...
@@ -109,12 +109,7 @@ class PythonScript(XMLObject, ZopePythonScript):
"""
override to call ZopePythonScript methods to force compiling code
"""
if
value
is
None
:
value
=
''
self
.
_baseSetParameterSignature
(
value
)
if
self
.
_params
is
None
or
''
:
### zwj: avoid NoneType parameters from generating in ZHtml edit page
delattr
(
self
,
"_params"
)
self
.
_compile
()
def
_setProxyRoleList
(
self
,
value
):
...
...
@@ -128,9 +123,6 @@ class PythonScript(XMLObject, ZopePythonScript):
def
edit
(
self
,
**
kw
):
XMLObject
.
edit
(
self
,
**
kw
)
# We need to take __setstate__ from ZopePythonScript in order to
# generate _v_ft attributes which is necessary to run the script
__setstate__
=
ZopePythonScript
.
__setstate__
InitializeClass
(
PythonScript
)
\ No newline at end of file
product/ERP5Workflow/Document/Transition.py
View file @
d301f95d
...
...
@@ -31,6 +31,7 @@ from AccessControl import ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.Accessor.Base
import
_evaluateTales
from
Products.DCWorkflow.Expression
import
StateChangeInfo
from
zLOG
import
LOG
,
ERROR
,
DEBUG
,
WARNING
class
Transition
(
XMLObject
):
...
...
@@ -64,22 +65,23 @@ class Transition(XMLObject):
if
form_kw
is
None
:
form_kw
=
{}
workflow
=
self
.
getParentValue
()
# Get variable values
state_bc_id
=
workflow
.
getStateBaseCategory
()
status_dict
=
workflow
.
getCurrentStatusDict
(
document
)
state_object
=
document
.
unrestrictedTraverse
(
status_dict
[
state_bc_id
])
# Call the before script
self
.
_executeBeforeScript
(
document
,
form_kw
=
form_kw
)
self
.
_executeBeforeScript
(
document
,
workflow
,
state_object
,
form_kw
=
form_kw
)
# Modify the state
self
.
_changeState
(
document
)
### zwj: update Role mapping, also in Workflow, initialiseDocument()
self
.
getParent
().
updateRoleMappingsFor
(
document
)
# Get variable values
status_dict
=
workflow
.
getCurrentStatusDict
(
document
)
status_dict
[
'undo'
]
=
0
# Modify workflow history
state_bc_id
=
workflow
.
getStateBaseCategory
()
status_dict
[
state_bc_id
]
=
document
.
getCategoryMembershipList
(
state_bc_id
)[
0
]
state_object
=
document
.
unrestrictedTraverse
(
status_dict
[
state_bc_id
])
object
=
workflow
.
getStateChangeInformation
(
document
,
state_object
,
transition
=
self
)
# Update all variables
...
...
@@ -102,7 +104,7 @@ class Transition(XMLObject):
workflow
.
_updateWorkflowHistory
(
document
,
status_dict
)
# Call the after script
self
.
_executeAfterScript
(
document
,
form_kw
=
form_kw
)
self
.
_executeAfterScript
(
document
,
workflow
,
state_object
,
form_kw
=
form_kw
)
def
_changeState
(
self
,
document
):
"""
...
...
@@ -114,25 +116,36 @@ class Transition(XMLObject):
state_bc_id
=
self
.
getParentValue
().
getStateBaseCategory
()
document
.
setCategoryMembership
(
state_bc_id
,
state
)
def
_executeAfterScript
(
self
,
document
,
form_kw
=
None
):
def
_executeAfterScript
(
self
,
document
,
workflow
,
state_object
,
form_kw
=
None
):
"""
Execute post transition script.
"""
former_status
=
state_object
.
getId
()
old_sdef
=
state_object
new_sdef
=
document
.
unrestrictedTraverse
(
self
.
getDestination
())
kwargs
=
form_kw
sci
=
StateChangeInfo
(
document
,
workflow
,
former_status
,
self
,
old_sdef
,
new_sdef
,
kwargs
)
if
form_kw
is
None
:
form_kw
=
{}
script_id
=
self
.
getAfterScriptId
()
if
script_id
is
not
None
:
script
=
self
.
getParent
().
_getOb
(
script_id
)
if
script
is
not
None
:
LOG
(
"zwj: Executing after script %s for %s"
%
(
script_id
,
self
.
getId
()),
WARNING
,
"in Transition.py."
)
#script(**form_kw) ### zwj: call the name of script to execute itself
script
.
execute
()
script
.
execute
(
sci
)
def
_executeBeforeScript
(
self
,
document
,
form_kw
=
None
):
def
_executeBeforeScript
(
self
,
document
,
workflow
,
state_object
,
form_kw
=
None
):
"""
Execute pre transition script.
"""
former_status
=
state_object
.
getId
()
old_sdef
=
state_object
new_sdef
=
document
.
unrestrictedTraverse
(
self
.
getDestination
())
kwargs
=
form_kw
sci
=
StateChangeInfo
(
document
,
workflow
,
former_status
,
self
,
old_sdef
,
new_sdef
,
kwargs
)
if
form_kw
is
None
:
form_kw
=
{}
script_id
=
self
.
getBeforeScriptId
()
...
...
@@ -143,7 +156,8 @@ class Transition(XMLObject):
if
script
is
not
None
:
LOG
(
"zwj: Executing before script %s for %s"
%
(
script_id
,
self
.
getId
()),
WARNING
,
"in Transition.py."
)
#script(**form_kw) ### zwj: call the name of script to execute itself
script
.
execute
()
script
.
execute
(
sci
)
def
_checkPermission
(
self
,
document
):
"""
...
...
product/ERP5Workflow/Document/Workflow.py
View file @
d301f95d
...
...
@@ -247,5 +247,6 @@ class Workflow(XMLObject):
out
.
append
(
'%s -> %s [label="%s"];'
%
(
k
[
0
],
k
[
1
],
',
\
\
n'
.
join
(
v
)))
out
.
append
(
'}'
)
return
'
\
n
'
.
join
(
out
)
product/ERP5Workflow/Document/WorkflowScript.py
View file @
d301f95d
...
...
@@ -52,13 +52,15 @@ class WorkflowScript(PythonScript):
def
__init__
(
self
,
*
args
,
**
kw
):
PythonScript
.
__init__
(
self
,
*
args
,
**
kw
)
LOG
(
'zwj: Init _params = %s'
%
self
.
_params
,
WARNING
,
' in WorkflowScript.py'
)
### zwj: override __call__ to access view page instead of executing script
def
__call__
(
self
):
r_url
=
self
.
REQUEST
.
get
(
'URL'
)
return
self
.
REQUEST
.
RESPONSE
.
redirect
(
r_url
+
'/view'
)
execute
=
PythonScript
.
__call__
# We need to take __setstate__ from PythonScript in order to
# generate _v_ft attributes which is necessary to run the script
__setstate__
=
PythonScript
.
__setstate__
InitializeClass
(
WorkflowScript
)
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