diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_createResponse.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_createResponse.xml index 6a44e3898098d9735eaeb5ad6596e101ae23c816..e521c502191866eaa3a9a2119f9b5e4c70ddb318 100644 --- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_createResponse.xml +++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_createResponse.xml @@ -74,8 +74,7 @@ if response_event_notification_message:\n \n message = portal.Base_translateString(\'Response Created.\')\n if response_workflow_action == \'send\':\n - # use doActionFor to initialise workflow variable\n - portal.portal_workflow.doActionFor(response, \'start_action\', send_mail=True)\n + response.start()\n return context.Base_redirect(form_id, keep_items={\'portal_status_message\': message})\n elif response_workflow_action == \'plan\':\n response.plan()\n diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewStartWorkflowActionDialog.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewStartWorkflowActionDialog.xml index 3193bd818f11d8d22c320717c98796868c1312fa..31db52e70a14b94e2d923d8cbb820dee06d9c541 100644 --- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewStartWorkflowActionDialog.xml +++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewStartWorkflowActionDialog.xml @@ -96,7 +96,6 @@ <string>your_comment</string> <string>your_workflow_action</string> <string>your_warning_message</string> - <string>your_send_mail</string> </list> </value> </item> diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewStartWorkflowActionDialog/your_send_mail.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewStartWorkflowActionDialog/your_send_mail.xml deleted file mode 100644 index 69d5c8b54637098d6f4d5ebde3b37bfbcc6d0d53..0000000000000000000000000000000000000000 --- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewStartWorkflowActionDialog/your_send_mail.xml +++ /dev/null @@ -1,186 +0,0 @@ -<?xml version="1.0"?> -<ZopeData> - <record id="1" aka="AAAAAAAAAAE="> - <pickle> - <global name="CheckBoxField" module="Products.Formulator.StandardFields"/> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>id</string> </key> - <value> <string>your_send_mail</string> </value> - </item> - <item> - <key> <string>message_values</string> </key> - <value> - <dictionary> - <item> - <key> <string>external_validator_failed</string> </key> - <value> <string>The input failed the external validator.</string> </value> - </item> - </dictionary> - </value> - </item> - <item> - <key> <string>overrides</string> </key> - <value> - <dictionary> - <item> - <key> <string>alternate_name</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>css_class</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>default</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>description</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>editable</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>enabled</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>external_validator</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>extra</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>hidden</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>title</string> </key> - <value> <string></string> </value> - </item> - </dictionary> - </value> - </item> - <item> - <key> <string>tales</string> </key> - <value> - <dictionary> - <item> - <key> <string>alternate_name</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>css_class</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>default</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>description</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>editable</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>enabled</string> </key> - <value> - <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> - </value> - </item> - <item> - <key> <string>external_validator</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>extra</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>hidden</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>title</string> </key> - <value> <string></string> </value> - </item> - </dictionary> - </value> - </item> - <item> - <key> <string>values</string> </key> - <value> - <dictionary> - <item> - <key> <string>alternate_name</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>css_class</string> </key> - <value> <string>invisible</string> </value> - </item> - <item> - <key> <string>default</string> </key> - <value> <int>1</int> </value> - </item> - <item> - <key> <string>description</string> </key> - <value> <string>When checked, this Mail Message will actually be sent to each recipient.</string> </value> - </item> - <item> - <key> <string>editable</string> </key> - <value> <int>1</int> </value> - </item> - <item> - <key> <string>enabled</string> </key> - <value> <int>1</int> </value> - </item> - <item> - <key> <string>external_validator</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>extra</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>hidden</string> </key> - <value> <int>1</int> </value> - </item> - <item> - <key> <string>title</string> </key> - <value> <string>Send Mail</string> </value> - </item> - </dictionary> - </value> - </item> - </dictionary> - </pickle> - </record> - <record id="2" aka="AAAAAAAAAAI="> - <pickle> - <tuple> - <global name="TALESMethod" module="Products.Formulator.TALESField"/> - <tuple/> - </tuple> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>_text</string> </key> - <value> <string>python: here.getPortalType() in (\'Mail Message\', )</string> </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> diff --git a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/scripts/Event_send.xml b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/scripts/Event_send.xml index b5b24c60bb288e51b69bd9c90519b75a5deb630b..87f214be567a62b5fd30f1dcbe5192e0c1c2dd86 100644 --- a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/scripts/Event_send.xml +++ b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/scripts/Event_send.xml @@ -52,11 +52,15 @@ <key> <string>_body</string> </key> <value> <string>event = state_change[\'object\']\n portal = event.getPortalObject()\n -send_mail = portal.portal_workflow.getInfoFor(event, \'send_mail\')\n -if send_mail and event.getPortalType() in (\'Mail Message\', ):\n +\n +# FIXME: we should always call send here, and the type based method must\n +# decide what to do.\n +\n +if event.getPortalType() in (\'Mail Message\', ):\n if event.getSource():\n event.send()\n else:\n + # FIXME: this "email only" logic must be moved to MailMessage_send\n sender_email = portal.portal_preferences.getPreferredEventSenderEmail()\n if not sender_email:\n raise NotImplementedError(\'Preferred Event Sender Email not configured\')\n diff --git a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/transitions/start_action.xml b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/transitions/start_action.xml index cc921c49e4d39c87292e6f8450fe2eb06de4a15c..fe70d7db552887a883398d1c761d9f503fa34791 100644 --- a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/transitions/start_action.xml +++ b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/transitions/start_action.xml @@ -93,30 +93,10 @@ <item> <key> <string>data</string> </key> <value> - <dictionary> - <item> - <key> <string>send_mail</string> </key> - <value> - <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> - </value> - </item> - </dictionary> + <dictionary/> </value> </item> </dictionary> </pickle> </record> - <record id="4" aka="AAAAAAAAAAQ="> - <pickle> - <global name="Expression" module="Products.CMFCore.Expression"/> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>text</string> </key> - <value> <string>kwargs/send_mail | nothing </string> </value> - </item> - </dictionary> - </pickle> - </record> </ZopeData> diff --git a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/variables/send_mail.xml b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/variables/send_mail.xml deleted file mode 100644 index 8e342106659958b585bd51b3cb6d277e492e71e8..0000000000000000000000000000000000000000 --- a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_simulation_workflow/variables/send_mail.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<ZopeData> - <record id="1" aka="AAAAAAAAAAE="> - <pickle> - <global name="VariableDefinition" module="Products.DCWorkflow.Variables"/> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>default_expr</string> </key> - <value> - <none/> - </value> - </item> - <item> - <key> <string>default_value</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>description</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>for_catalog</string> </key> - <value> <int>0</int> </value> - </item> - <item> - <key> <string>for_status</string> </key> - <value> <int>1</int> </value> - </item> - <item> - <key> <string>id</string> </key> - <value> <string>send_mail</string> </value> - </item> - <item> - <key> <string>info_guard</string> </key> - <value> - <none/> - </value> - </item> - <item> - <key> <string>update_always</string> </key> - <value> <int>0</int> </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> diff --git a/bt5/erp5_crm/bt/revision b/bt5/erp5_crm/bt/revision index 9251196df347629db89caa8098b7b3316365f168..55b7e8800fb8c1773ea6ddba87bdf9af232bc300 100644 --- a/bt5/erp5_crm/bt/revision +++ b/bt5/erp5_crm/bt/revision @@ -1 +1 @@ -678 \ No newline at end of file +680 \ No newline at end of file diff --git a/product/ERP5/tests/testCRM.py b/product/ERP5/tests/testCRM.py index 37ff9acd8eef1c531654dcf9333a37b45c8d8e29..b66fb40af424b193e5ef89591ec58aca65658f93 100644 --- a/product/ERP5/tests/testCRM.py +++ b/product/ERP5/tests/testCRM.py @@ -1028,8 +1028,7 @@ class TestCRMMailSend(BaseTestCRM): event.setDestination('person_module/recipient') event.setTitle('A Mail') event.setTextContent(text_content) - self.portal.portal_workflow.doActionFor(event, 'start_action', - send_mail=1) + self.portal.portal_workflow.doActionFor(event, 'start_action') self.tic() last_message = self.portal.MailHost._last_message self.assertNotEquals((), last_message) @@ -1055,8 +1054,7 @@ class TestCRMMailSend(BaseTestCRM): event.setDestinationList(['person_module/recipient', 'person_module/me']) event.setTitle('A Mail') event.setTextContent(text_content) - self.portal.portal_workflow.doActionFor(event, 'start_action', - send_mail=1) + self.portal.portal_workflow.doActionFor(event, 'start_action') self.tic() last_message_1, last_message_2 = self.portal.MailHost._message_list[-2:] self.assertNotEquals((), last_message_1) @@ -1070,19 +1068,20 @@ class TestCRMMailSend(BaseTestCRM): sorted([x[1] for x in (last_message_1, last_message_2)])) def test_MailFromMailMessageEventNoSendMail(self): - # passing start_action transition on event workflow will send an email to the - # person as destination, unless you don't check "send_mail" box in the - # workflow dialog + # for Mail Message, passing start_action transition on event workflow will send an email to the + # person as destination. To prevent this, one can use initial_stop_action to mark + # the event receieved. event = self.portal.event_module.newContent(portal_type='Mail Message') event.setSource('person_module/me') event.setDestination('person_module/recipient') event.setTitle('A Mail') event.setTextContent('Mail Content') - self.portal.portal_workflow.doActionFor(event, 'start_action', - send_mail=1) + self.portal.portal_workflow.doActionFor(event, 'initial_stop_action') + self.assertEquals('stopped', event.getSimulationState()) self.tic() # no mail sent last_message = self.portal.MailHost._last_message + self.assertEquals((), last_message) def test_MailFromOtherEvents(self): # passing start_action transition on event workflow will not send an email @@ -1094,30 +1093,12 @@ class TestCRMMailSend(BaseTestCRM): event.setSource('person_module/me') event.setDestination('person_module/recipient') event.setTextContent('Hello !') - self.portal.portal_workflow.doActionFor(event, 'start_action', - send_mail=1) - - self.tic() - # this means no message have been set - self.assertEquals((), self.portal.MailHost._last_message) - - def test_MailMarkPosted(self): - # start_action transition without send_mail variable on event - # simulation workflow will not send an email even if the portal - # type is a Mail Message - for ptype in [x for x in self.portal.getPortalEventTypeList() if x != - 'Acknowledgement']: - event = self.portal.event_module.newContent(portal_type=ptype) - event.setSource('person_module/me') - event.setDestination('person_module/recipient') - event.setTextContent('Hello !') self.portal.portal_workflow.doActionFor(event, 'start_action') self.tic() # this means no message have been set self.assertEquals((), self.portal.MailHost._last_message) - def test_MailMessageHTML(self): # test sending a mail message edited as HTML (the default with FCKEditor), # then the mail should have HTML. @@ -1127,8 +1108,7 @@ class TestCRMMailSend(BaseTestCRM): event.setDestination('person_module/recipient') event.setContentType('text/html') event.setTextContent(text_content) - self.portal.portal_workflow.doActionFor(event, 'start_action', - send_mail=1) + self.portal.portal_workflow.doActionFor(event, 'start_action') self.tic() # content type is kept self.assertEquals(event.getContentType(), 'text/html') @@ -1159,8 +1139,7 @@ class TestCRMMailSend(BaseTestCRM): event.setDestination('person_module/recipient') event.setTitle('Héhé') event.setTextContent('Hà hà ') - self.portal.portal_workflow.doActionFor(event, 'start_action', - send_mail=1) + self.portal.portal_workflow.doActionFor(event, 'start_action') self.tic() last_message = self.portal.MailHost._last_message self.assertNotEquals((), last_message)