diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_afterClone.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_afterClone.xml index 6b9eafcab33a8ab35dce23a225654d204c9c529e..0294ec7228dcc63803f85af329a45aab4a7ef648 100644 --- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_afterClone.xml +++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_afterClone.xml @@ -63,8 +63,9 @@ content_dict[\'destination_list\'] = content_dict.get(\'destination_list\', []) content_dict[\'source_list\'] = content_dict.get(\'source_list\', []) + \\\n [x.getRelativeUrl() for x in context.getSourceValueList() \\\n if x.getRelativeUrl() not in content_dict.get(\'source_list\', [])]\n -\n context.edit(**content_dict)\n +# reset reference\n +context.Event_generateReference()\n </string> </value> </item> <item> diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_generateReference.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_generateReference.xml new file mode 100644 index 0000000000000000000000000000000000000000..3a7948ddb437980c3f00ec67c189e1cc26c64922 --- /dev/null +++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_generateReference.xml @@ -0,0 +1,88 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_body</string> </key> + <value> <string>"""Owner Proxy Role allows anonymous users to create events\n +through web sites. cf. Event_init\n +"""\n +portal = context.getPortalObject()\n +type_definition = context.getTypeInfo()\n +\n +short_portal_type = type_definition.getShortTitle()\n +if not short_portal_type:\n + short_portal_type = \'\'.join(s for s in type_definition.getId() if s.isupper())\n +\n +new_id = portal.portal_ids.generateNewId(id_group=repr((\'reference\', short_portal_type)), default=1)\n +reference = \'%s-%s\' % (short_portal_type, new_id)\n +\n +context.setReference(reference)\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>_proxy_roles</string> </key> + <value> + <tuple> + <string>Owner</string> + </tuple> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Event_generateReference</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_init.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_init.xml index 23eace19723fd95958ceb94e1ce3022efb72e58f..e6755f930ca2bb25ea2a671bae57ceec68a6b64e 100644 --- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_init.xml +++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_init.xml @@ -52,23 +52,11 @@ <key> <string>_body</string> </key> <value> <string>"""Owner Proxy Role allows anonymous users to create events\n through web sites.\n -\n -Reference will be probably generated with dedicated tool\n -in near future\n """\n portal = context.getPortalObject()\n -type_definition = context.getTypeInfo()\n -\n -short_portal_type = type_definition.getShortTitle()\n -if not short_portal_type:\n - short_portal_type = \'\'.join(s for s in type_definition.getId() if s.isupper())\n -\n -new_id = portal.portal_ids.generateNewId(id_group=repr((\'reference\', short_portal_type)), default=1)\n -reference = \'%s-%s\' % (short_portal_type, new_id)\n -\n # Set preferred text format and reference\n -context.setContentType(context.portal_preferences.getPreferredTextFormat())\n -context.setReference(reference)\n +context.setContentType(portal.portal_preferences.getPreferredTextFormat())\n +context.Event_generateReference()\n </string> </value> </item> <item> diff --git a/product/ERP5/tests/testCRM.py b/product/ERP5/tests/testCRM.py index d655bf0a10a75cb5a1ba2586107ba0a9af94bf4e..c026ac3688e3f82a90c243ef2c23de5199277f26 100644 --- a/product/ERP5/tests/testCRM.py +++ b/product/ERP5/tests/testCRM.py @@ -725,6 +725,9 @@ class TestCRMMailIngestion(BaseTestCRM): self.assertEquals(new_event.getDestinationList(), ['person_module/me', 'person_module/he']) + # cloned event got a new reference + self.assertNotEqual(new_event.getReference(), event.getReference()) + def test_follow_up(self): # follow up is found automatically, based on the content of the mail, and # what you defined in preference regexpr. @@ -1575,6 +1578,7 @@ class TestCRMMailSend(BaseTestCRM): self.assertEquals(new_event.getData(), '') self.assertEquals(new_event.getTitle(), real_title) self.assertEquals(new_event.getTextContent(), real_content) + self.assertNotEquals(new_event.getReference(), event.getReference()) def test_cloneTicketAndEventList(self): """