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
b5e8f8c4
Commit
b5e8f8c4
authored
Mar 20, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transition.py: Add erp5 variables compatibility.
parent
79b666bd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
41 deletions
+54
-41
product/ERP5Workflow/Document/Transition.py
product/ERP5Workflow/Document/Transition.py
+54
-41
No files found.
product/ERP5Workflow/Document/Transition.py
View file @
b5e8f8c4
...
@@ -32,7 +32,7 @@ from Products.ERP5Type import Permissions, PropertySheet
...
@@ -32,7 +32,7 @@ from Products.ERP5Type import Permissions, PropertySheet
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.Accessor.Base
import
_evaluateTales
from
Products.ERP5Type.Accessor.Base
import
_evaluateTales
from
Products.ERP5Type.Globals
import
PersistentMapping
from
Products.ERP5Type.Globals
import
PersistentMapping
from
Products.DCWorkflow.Expression
import
StateChangeInfo
,
createExprContext
from
Products.DCWorkflow.Expression
import
StateChangeInfo
from
zLOG
import
LOG
,
ERROR
,
DEBUG
,
WARNING
from
zLOG
import
LOG
,
ERROR
,
DEBUG
,
WARNING
from
Products.ERP5Type.Utils
import
convertToUpperCase
,
convertToMixedCase
from
Products.ERP5Type.Utils
import
convertToUpperCase
,
convertToMixedCase
from
Products.DCWorkflow.DCWorkflow
import
ObjectDeleted
,
ObjectMoved
from
Products.DCWorkflow.DCWorkflow
import
ObjectDeleted
,
ObjectMoved
...
@@ -40,7 +40,9 @@ from Products.ERP5Type.patches.DCWorkflow import ValidationFailed
...
@@ -40,7 +40,9 @@ from Products.ERP5Type.patches.DCWorkflow import ValidationFailed
from
copy
import
deepcopy
from
copy
import
deepcopy
import
sys
import
sys
from
Products.ERP5Type.patches.WorkflowTool
import
WorkflowHistoryList
from
Products.ERP5Type.patches.WorkflowTool
import
WorkflowHistoryList
from
Products.ERP5Type.patches.Expression
import
Expression_createExprContext
from
Products.DCWorkflow.Guard
import
Guard
from
Products.DCWorkflow.Guard
import
Guard
from
Products.CMFCore.Expression
import
Expression
TRIGGER_AUTOMATIC
=
0
TRIGGER_AUTOMATIC
=
0
TRIGGER_USER_ACTION
=
1
TRIGGER_USER_ACTION
=
1
...
@@ -211,31 +213,38 @@ class Transition(XMLObject):
...
@@ -211,31 +213,38 @@ class Transition(XMLObject):
status_dict
[
state_bc_id
]
=
new_state
status_dict
[
state_bc_id
]
=
new_state
object
=
workflow
.
getStateChangeInformation
(
document
,
state_object
,
transition
=
self
)
object
=
workflow
.
getStateChangeInformation
(
document
,
state_object
,
transition
=
self
)
"""
# update variables =========================================================
# Update all variables
state_values
=
None
state_values
=
None
if
new_sdef
is
not
None
:
if
new_sdef
is
not
None
:
state_values = new_sdef.objectValues(portal_type="Variable")
state_values
=
new_sdef
.
objectValues
(
portal_type
=
'Variable'
)
if state_values is None: state_values = {}
if
state_values
is
None
:
tdef_exprs = self.getGuardExpression()
state_values
=
{}
if tdef_exprs is None or 'python: True': tdef_exprs = {}
#status = {}
tdef_exprs
=
self
.
objectValues
(
portal_type
=
'Variable'
)
for variable in workflow.objectValues(portal_type="Variable"):
if
tdef_exprs
is
None
:
if not variable.for_status:
tdef_exprs
=
{}
#status = {} ### zwj: here replace by status_dict
#for id, vdef in workflow.objectValues(portal_type='Variable').items():
for
vdef
in
workflow
.
objectValues
(
portal_type
=
'Variable'
):
id
=
vdef
.
getId
()
if
not
vdef
.
for_status
:
continue
continue
expr
=
None
expr
=
None
if state_values.has_key(id)
:
if
id
in
state_values
:
value
=
state_values
[
id
]
value
=
state_values
[
id
]
elif tdef_exprs.has_key(id)
:
elif
id
in
tdef_exprs
:
expr
=
tdef_exprs
[
id
]
expr
=
tdef_exprs
[
id
]
elif not variable.update_always and former_status.has_key(id)
:
elif
not
vdef
.
update_always
and
id
in
former_status
:
# Preserve former value
# Preserve former value
value
=
former_status
[
id
]
value
=
former_status
[
id
]
else
:
else
:
if variable
.default_expr is not None:
if
vdef
.
default_expr
is
not
None
:
expr = variable
.default_expr
expr
=
vdef
.
default_expr
else
:
else
:
value = variable
.default_value
value
=
vdef
.
default_value
if
expr
is
not
None
:
if
expr
is
not
None
:
# Evaluate an expression.
# Evaluate an expression.
if
econtext
is
None
:
if
econtext
is
None
:
...
@@ -243,13 +252,15 @@ class Transition(XMLObject):
...
@@ -243,13 +252,15 @@ class Transition(XMLObject):
if
sci
is
None
:
if
sci
is
None
:
kwargs
=
form_kw
kwargs
=
form_kw
sci
=
StateChangeInfo
(
sci
=
StateChangeInfo
(
document, self
, former_status, self,
document
,
workflow
,
former_status
,
self
,
old_sdef
,
new_sdef
,
kwargs
)
old_sdef
,
new_sdef
,
kwargs
)
econtext = createExprContext(sci)
econtext
=
Expression_createExprContext
(
sci
)
#raise NotImplementedError (expr) # transition/getId|nothing
expr
=
Expression
(
expr
)
value
=
expr
(
econtext
)
value
=
expr
(
econtext
)
status_dict
[
id
]
=
value
status_dict
[
id
]
=
value
# ==========================================================================
"""
# Update all transition variables
# Update all transition variables
if
form_kw
is
not
None
:
if
form_kw
is
not
None
:
object
.
REQUEST
.
other
.
update
(
form_kw
)
object
.
REQUEST
.
other
.
update
(
form_kw
)
...
@@ -257,16 +268,18 @@ class Transition(XMLObject):
...
@@ -257,16 +268,18 @@ class Transition(XMLObject):
for
variable
in
self
.
contentValues
(
portal_type
=
'Transition Variable'
):
for
variable
in
self
.
contentValues
(
portal_type
=
'Transition Variable'
):
status_dict
[
variable
.
getCausalityTitle
()]
=
variable
.
getInitialValue
(
object
=
object
)
status_dict
[
variable
.
getCausalityTitle
()]
=
variable
.
getInitialValue
(
object
=
object
)
"""
# Update all variables
# Update all variables
for variable in workflow.contentValues(portal_type='Variable'):
for variable in workflow.contentValues(portal_type='Variable'):
if
variable
.
getAutomaticUpdate
():
if variable.getAutomaticUpdate()
== 1
:
# if we have it in form get it from there
# if we have it in form get it from there
# otherwise use default
# otherwise use default
variable_
title
=
variable
.
getTitle
()
variable_
id = variable.getId
()
if
variable_
title
in
form_kw
:
if variable_
id
in form_kw:
status_dict
[
variable_
title
]
=
form_kw
[
variable_title
]
status_dict[variable_
id] = form_kw[variable_id
]
else:
else:
status_dict
[
variable_title
]
=
variable
.
getInitialValue
(
object
=
object
)
status_dict[variable_id] = variable.getInitialValue(object=object)
"""
# Generate Workflow History List
# Generate Workflow History List
self
.
setStatusOf
(
workflow
.
getId
(),
document
,
status_dict
)
self
.
setStatusOf
(
workflow
.
getId
(),
document
,
status_dict
)
...
...
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