From 3270183e737e803d5c8c58d113a60bbe010805fe Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Mon, 5 Aug 2013 15:57:14 +0200
Subject: [PATCH] erp5_crm: add batch_mode to PersonModule_newEvent to allow
 calls from another script

---
 .../portal_skins/erp5_crm/PersonModule_newEvent.xml       | 8 +++++++-
 bt5/erp5_crm/bt/revision                                  | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/PersonModule_newEvent.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/PersonModule_newEvent.xml
index b3a706575c..d545c7a020 100644
--- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/PersonModule_newEvent.xml
+++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/PersonModule_newEvent.xml
@@ -68,6 +68,7 @@ if not person_list:\n
 user = context.portal_membership.getAuthenticatedMember()\n
 user_person = context.portal_catalog.getResultValue(portal_type=\'Person\', reference=str(user))\n
 \n
+event_list = []\n
 # For every person, create an event\n
 if not single_event:\n
   count = 0\n
@@ -88,6 +89,7 @@ if not single_event:\n
       event.setDestinationValue(person.getObject())\n
       event.setSourceValue(user_person)\n
       event.plan()\n
+    event_list.append(event)\n
 else:\n
   if direction == \'incoming\' and len(person_list) > 1:\n
     # This case is not possible\n
@@ -104,6 +106,10 @@ else:\n
   event.setSourceValue(user_person)\n
   event.plan()\n
   count = 1\n
+  event_list.append(event)\n
+\n
+if batch_mode:\n
+  return event_list\n
 \n
 portal_status_message = translateString("Created and associated ${count} new events to the selected ticket.", \n
                                         mapping=dict(count=count))\n
@@ -115,7 +121,7 @@ context.Base_redirect(form_id, keep_items = dict(portal_status_message=portal_st
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>portal_type, title, description, direction, selection_name, follow_up=None, single_event=0, text_content=None, form_id=None, **kw</string> </value>
+            <value> <string>portal_type, title, description, direction, selection_name, follow_up=None, single_event=0, text_content=None, form_id=None, batch_mode=0, **kw</string> </value>
         </item>
         <item>
             <key> <string>id</string> </key>
diff --git a/bt5/erp5_crm/bt/revision b/bt5/erp5_crm/bt/revision
index f95076e1d6..8e3d0d813a 100644
--- a/bt5/erp5_crm/bt/revision
+++ b/bt5/erp5_crm/bt/revision
@@ -1 +1 @@
-662
\ No newline at end of file
+663
\ No newline at end of file
-- 
2.30.9