Commit c6b59bd6 authored by Jérome Perrin's avatar Jérome Perrin

crm,credential: repair Ticket_getWorkflowStateTranslatedTitle for ERP5 workflow

`state_var` is now a compatibility alias calling getStateVariable, which
has a default value of `simulation_state`. As a result, this script was
attempting to call getSimulationStateTranslatedTitle on credential
requests, because they have an interaction workflow in their chain.

This fixes by implementing the full logic using new ERP5 workflow API.
parent 1832ca00
...@@ -1535,6 +1535,19 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -1535,6 +1535,19 @@ class TestERP5Credential(ERP5TypeTestCase):
self.assertEqual(cr.getDefaultAddressCity(), None) self.assertEqual(cr.getDefaultAddressCity(), None)
self.assertEqual(cr.getDefaultAddressRegion(), None) self.assertEqual(cr.getDefaultAddressRegion(), None)
def test_Ticket_getWorkflowStateTranslatedTitle(self):
self.assertEqual(
self.portal.credential_recovery_module.newContent(
portal_type='Credential Recovery').Ticket_getWorkflowStateTranslatedTitle(),
'Draft')
self.assertEqual(
self.portal.credential_request_module.newContent(
portal_type='Credential Request').Ticket_getWorkflowStateTranslatedTitle(),
'Draft')
self.assertEqual(
self.portal.credential_update_module.newContent(
portal_type='Credential Update').Ticket_getWorkflowStateTranslatedTitle(),
'Draft')
def test_suite(): def test_suite():
......
...@@ -4,6 +4,6 @@ portal = context.getPortalObject() ...@@ -4,6 +4,6 @@ portal = context.getPortalObject()
workflow_tool = portal.portal_workflow workflow_tool = portal.portal_workflow
for workflow in workflow_tool.getWorkflowValueListFor(context): for workflow in workflow_tool.getWorkflowValueListFor(context):
# Exclude interaction workflows and edit_workflow if workflow.getPortalType() != 'Interaction Workflow' \
if workflow.state_var != 'state': and workflow.getId() != 'edit_workflow':
return getattr(context, 'getTranslated%sTitle' % UpperCase(workflow.state_var))() return getattr(context, 'getTranslated%sTitle' % UpperCase(workflow.getStateVariable()))()
...@@ -344,6 +344,24 @@ class TestCRM(BaseTestCRM): ...@@ -344,6 +344,24 @@ class TestCRM(BaseTestCRM):
self.portal.portal_workflow.doActionFor(so, 'expire_action') self.portal.portal_workflow.doActionFor(so, 'expire_action')
self.assertEqual('expired', so.getSimulationState()) self.assertEqual('expired', so.getSimulationState())
def test_Ticket_getWorkflowStateTranslatedTitle(self):
self.assertEqual(
self.portal.campaign_module.newContent(
portal_type='Campaign').Ticket_getWorkflowStateTranslatedTitle(),
'Draft')
self.assertEqual(
self.portal.meeting_module.newContent(
portal_type='Meeting').Ticket_getWorkflowStateTranslatedTitle(),
'Draft')
self.assertEqual(
self.portal.support_request_module.newContent(
portal_type='Support Request').Ticket_getWorkflowStateTranslatedTitle(),
'Draft')
self.assertEqual(
self.portal.sale_opportunity_module.newContent(
portal_type='Sale Opportunity').Ticket_getWorkflowStateTranslatedTitle(),
'Draft')
@expectedFailure @expectedFailure
def test_Event_AcknowledgeAndCreateEvent(self): def test_Event_AcknowledgeAndCreateEvent(self):
""" """
......
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