From 743f36ab94361111f1e80f3e54d2bf44566603f2 Mon Sep 17 00:00:00 2001
From: Thibaut Deheunynck <thibaut@nexedi.com>
Date: Mon, 18 Aug 2008 09:00:21 +0000
Subject: [PATCH] thibaut improve script modifyPhysicalPersonFromP2. Now we can
 remove and add activities with the same form Edit the corporate registration
 code according to the different cases

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23012 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../scripts/modifyPhysicalPersonFromP2.xml               | 9 +++++++--
 bt5/erp5_registry_ohada/bt/revision                      | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/modifyPhysicalPersonFromP2.xml b/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/modifyPhysicalPersonFromP2.xml
index cbf0d7c105..2faeff3482 100644
--- a/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/modifyPhysicalPersonFromP2.xml
+++ b/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/modifyPhysicalPersonFromP2.xml
@@ -152,6 +152,8 @@ else:\n
   #address, or its corporate name or whether the P2 form is used to create another\n
   #company for the person\n
   if request_eform.getCompanyModifications():\n
+    corporate_registration_code = request_eform.getCompanyCorporateRegistrationCode()\n
+    request_eform.edit(corporate_registration_code=corporate_registration_code)\n
     organisation_list = [organisation.getObject() for organisation in \\\n
         organisation_module.searchFolder(corporate_registration_code=request_eform.getCorporateRegistrationCode())]\n
     for organisation in organisation_list:\n
@@ -168,7 +170,7 @@ else:\n
             if removed_activities in activity_list:\n
               activity_list.remove(removed_activities)\n
               organisation.edit(activity_free_text = \',\'.join(activity_list))\n
-        elif request_eform.getCompanyModifiedAddedActivities() != None:\n
+        if request_eform.getCompanyModifiedAddedActivities() != None:\n
           activity_list.append(request_eform.getCompanyModifiedAddedActivities())\n
           organisation.edit(activity_free_text = \',\'.join(activity_list))\n
 \n
@@ -193,8 +195,10 @@ else:\n
   #If the person has secondaries organisations,\n
   #modify the secondaries organisations for the person\n
   elif request_eform.getEstablishmentModification():\n
+    corporate_registration_code = request_eform.getEstablishmentRegistrationCode()\n
+    request_eform.edit(corporate_registration_code=corporate_registration_code)\n
     organisation_list = [organisation.getObject() for organisation in \\\n
-        organisation_module.searchFolder(corporate_registration_code=request_eform.getNewCorporateRegistrationCode())]\n
+        organisation_module.searchFolder(corporate_registration_code=request_eform.getCorporateRegistrationCode())]\n
     for organisation in organisation_list:\n
       if request_eform.getClosingCheck():\n
         organisation.getDefaultAddress().close()\n
@@ -294,6 +298,7 @@ for history in history_list:\n
                             <string>person_list</string>
                             <string>len</string>
                             <string>ValidationFailed</string>
+                            <string>corporate_registration_code</string>
                             <string>organisation</string>
                             <string>organisation_list</string>
                             <string>activity_free_text</string>
diff --git a/bt5/erp5_registry_ohada/bt/revision b/bt5/erp5_registry_ohada/bt/revision
index 2379a17515..03204565ba 100644
--- a/bt5/erp5_registry_ohada/bt/revision
+++ b/bt5/erp5_registry_ohada/bt/revision
@@ -1 +1 @@
-910
\ No newline at end of file
+911
\ No newline at end of file
-- 
2.30.9