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
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
7361e9c4
Commit
7361e9c4
authored
Mar 28, 2024
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Base: add getTransitionEffectiveDate and getTransitionDate
parent
c899c714
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
product/ERP5Type/Accessor/WorkflowHistory.py
product/ERP5Type/Accessor/WorkflowHistory.py
+53
-0
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+19
-0
No files found.
product/ERP5Type/Accessor/WorkflowHistory.py
View file @
7361e9c4
...
...
@@ -81,3 +81,56 @@ class Getter(BaseGetter):
return
default
psyco
.
bind
(
__call__
)
class
GenericKeyGetter
(
Getter
):
"""
Get 'key' property from Workflow History latest Transition. A
default value can be provided if needed.
"""
def
__call__
(
self
,
instance
,
workflow_id
,
transition_id
,
default
=
None
):
value_list
=
getattr
(
instance
,
self
.
_list_accessor_name
)(
workflow_id
,
transition_id
)
try
:
return
value_list
[
-
1
]
except
IndexError
:
return
default
psyco
.
bind
(
__call__
)
class
GenericKeyListGetter
(
BaseGetter
):
"""
List getter to get a key of a transition for a workflow
"""
def
__init__
(
self
,
id
,
key
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
workflow_id
,
transition_id
,
*
args
):
try
:
default
=
args
[
0
]
except
IndexError
:
default
=
[]
instance
=
aq_base
(
instance
)
try
:
workflow_history_dict_list
=
instance
.
workflow_history
[
workflow_id
]
except
(
AttributeError
,
KeyError
):
return
default
else
:
result_list
=
[]
action_result_list
=
[]
# Key may be on the action or the transition
action_transition_id
=
None
if
transition_id
.
endswith
(
"_action"
)
else
transition_id
+
"_action"
for
workflow_history_dict
in
workflow_history_dict_list
:
if
workflow_history_dict
[
'action'
]
==
transition_id
:
value
=
workflow_history_dict
.
get
(
self
.
_key
)
if
value
:
result_list
.
append
(
value
)
elif
workflow_history_dict
[
'action'
]
==
action_transition_id
:
value
=
workflow_history_dict
.
get
(
self
.
_key
)
if
value
:
action_result_list
.
append
(
value
)
return
result_list
if
result_list
else
action_result_list
if
action_result_list
else
default
psyco
.
bind
(
__call__
)
\ No newline at end of file
product/ERP5Type/Base.py
View file @
7361e9c4
...
...
@@ -524,10 +524,29 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow):
workflow_dict
=
{}
interaction_workflow_dict
=
{}
for
wf
in
portal_workflow
.
getWorkflowValueListFor
(
portal_type
):
wf_id
=
wf
.
getId
()
wf_type
=
wf
.
__class__
.
__name__
wf_transition_reference_list
=
wf
.
getTransitionReferenceList
()
method_setting_list
=
[
(
'getTransitionDate'
,
'time'
),
(
'getTransitionEffectiveDate'
,
'effective_time'
),
]
for
method_id
,
parameter
in
method_setting_list
:
list_method_id
=
method_id
+
"List"
if
not
hasattr
(
ptype_klass
,
list_method_id
):
method
=
WorkflowHistoryAccessor
.
GenericKeyListGetter
(
list_method_id
,
parameter
)
ptype_klass
.
registerAccessor
(
method
,
Permissions
.
AccessContentsInformation
)
if
not
hasattr
(
ptype_klass
,
method_id
):
method
=
WorkflowHistoryAccessor
.
GenericKeyGetter
(
method_id
,
list_method_id
)
ptype_klass
.
registerAccessor
(
method
,
Permissions
.
AccessContentsInformation
)
if
wf_type
in
[
'DCWorkflowDefinition'
,
'Workflow'
]:
# Create state var accessor
# and generate methods that support the translation of workflow states
...
...
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