Commit c6b48d38 authored by Julien Muchembled's avatar Julien Muchembled

Speed up getCreationDate

/reviewed-on nexedi/erp5!934
parent 2e8be7fc
...@@ -3212,20 +3212,20 @@ class Base( CopyContainer, ...@@ -3212,20 +3212,20 @@ class Base( CopyContainer,
""" """
Returns the creation date of the document based on workflow information Returns the creation date of the document based on workflow information
""" """
# Check if edit_workflow defined try:
portal_workflow = self.getPortalObject().portal_workflow history_list = aq_base(self).workflow_history
wf = portal_workflow.getWorkflowById('edit_workflow') except AttributeError:
wf_list = portal_workflow.getWorkflowsFor(self) pass
if wf is not None: else:
wf_list = [wf] + wf_list
for wf in wf_list:
try: try:
history = wf.getInfoFor(self, 'history', None) return history_list['edit_workflow'][0]['time']
except KeyError: except LookupError:
history = None try:
if history is not None and len(history): return min(history[0]['time']
# Then get the first line of edit_workflow for history in history_list.itervalues()
return history[0].get('time', None) if history)
except ValueError:
pass
if getattr(aq_base(self), 'CreationDate', None) is not None: if getattr(aq_base(self), 'CreationDate', None) is not None:
return asDate(self.CreationDate()) return asDate(self.CreationDate())
return None # JPS-XXX - try to find a way to return a creation date instead of None return None # JPS-XXX - try to find a way to return a creation date instead of None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment