[Erp5-report] r22994 - in /erp5/trunk/bt5/erp5_registry_ohada: WorkflowTemplateItem/portal_...
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Aug 14 12:18:22 CEST 2008
Author: fabien
Date: Thu Aug 14 12:18:20 2008
New Revision: 22994
URL: http://svn.erp5.org?rev=22994&view=rev
Log:
update createPersonFromP0 workflow script to be able to works in all cases (depending on checkboxes)
Modified:
erp5/trunk/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/createPersonFromP0.xml
erp5/trunk/bt5/erp5_registry_ohada/bt/revision
Modified: erp5/trunk/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/createPersonFromP0.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/createPersonFromP0.xml?rev=22994&r1=22993&r2=22994&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/createPersonFromP0.xml (original)
+++ erp5/trunk/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/createPersonFromP0.xml Thu Aug 14 12:18:20 2008
@@ -74,16 +74,37 @@
# Initalize some useful variables\n
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
+from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
+\n
request_eform = state_change[\'object\']\n
portal = request_eform.getPortalObject()\n
person_module = portal.person_module\n
organisation_module = portal.organisation_module\n
-organisation = organisation_module.newContent(portal_type=\'Organisation\')\n
-organisation.edit(role = \'commerce/siege\',\n
- title = request_eform.getLogo(),\n
- corporate_name = request_eform.getLogo(),\n
- activity_free_text = request_eform.getMainActivityFreeText(),\n
- default_address_street_address = request_eform.getRealAddress())\n
+organisation = None\n
+if not request_eform.getActivityRestartCheck():\n
+ organisation = organisation_module.newContent(portal_type=\'Organisation\')\n
+ organisation.edit(title = request_eform.getLogo(),\n
+ corporate_name = request_eform.getLogo(),\n
+ activity_free_text = request_eform.getMainActivityFreeText(),\n
+ default_address_street_address = request_eform.getRealAddress())\n
+else:\n
+ rccm = request_eform.getPreviousActivityCorporateRegistrationCode()\n
+ if rccm :\n
+ organisation_list = portal.organisation_module.searchFolder(\\\n
+ corporate_registration_code=rccm)\n
+ if len(organisation_list) >1 :\n
+ raise ValidationFailed, "Error : There is more than one organisation with the "\\\n
+ " rccm number \'%s\'" % rccm\n
+ elif len(organisation_list) == 0:\n
+ raise ValidationFailed, "Error : There is no organisation with the "\\\n
+ " rccm number \'%s\'" % rccm\n
+ organisation = organisation_list[0].getObject()\n
+\n
+if request_eform.getBeginning():\n
+ organisation.setRole(\'commerce/siege\')\n
+if request_eform.getOpening():\n
+ organisation.setRole(\'commerce/succursale\')\n
+\n
date = request_eform.getDate()\n
# Create a new person based on eform data\n
# we suppose here that all data in the form has\n
@@ -125,53 +146,54 @@
Query(birthplace_city=request_eform.getDefaultBirthplaceAddressCity()),\n
operator="AND")\n
person_list = [person.getObject() for person in person_module.searchFolder(query=query)]\n
-if len(person_list) == 0:\n
- person = person_module.newContent(portal_type=\'Person\')\n
- person.edit(\n
- first_name = request_eform.getFirstName(),\n
- last_name = request_eform.getLastName(),\n
- default_address_street_address = request_eform.getHeadOfficeAddress(),\n
- start_date = request_eform.getStartDate(),\n
- default_birthplace_address_city = request_eform.getDefaultBirthplaceAddressCity(),\n
- default_address_city = request_eform.getPlace(),\n
- nationality = request_eform.getCitizenship().lower())\n
- # Update matrimonial situation for the person\n
- if request_eform.getMarriedCheck():\n
- person.edit(marital_status = \'married\')\n
- elif request_eform.getDivorcedCheck():\n
- person.edit(marital_status = \'divorced\')\n
- elif request_eform.getSingleCheck():\n
- person.edit(marital_status = \'single\')\n
- elif request_eform.getWidowerCheck():\n
- person.edit(marital_status = \'widowed\')\n
- if request_eform.getMrCheck():\n
- person.edit(gender = \'male\')\n
- else:\n
- person.edit(gender = \'female\')\n
-\n
-else: # person exists\n
- if len(person_list) >1 :\n
- raise ValidationFailed, "Error : There is more than one person with the "\\\n
- " title \'%s\', birth date \'%s\' and birthplace \'%s\'" % (request_eform.getTitle(),\n
- request_eform.getStartDate(),\n
- request_eform.getDefaultBirthplaceAddressCity())\n
- elif len(person_list) == 0:\n
- raise ValidationFailed, "Error : There is nobody with the "\\\n
- " title \'%s\', birth date \'%s\' and birthplace \'%s\'" % (request_eform.getTitle(),\n
- request_eform.getStartDate(),\n
- request_eform.getDefaultBirthplaceAddressCity())\n
- else:\n
- person = person_list[0]\n
-\n
-# add a new assignment to this person\n
-assignment = person.newContent(portal_type=\'Assignment\',\n
- function=\'commerce/commercant\',\n
- start_date=request_eform.getBeginningDate(),\t\n
- destination_form_value=request_eform,\n
- destination_value=organisation)\n
-assignment.openSubmit()\n
-assignment.open()\n
-person.updateLocalRolesOnSecurityGroups()\n
+if request_eform.getBeginning() or request_eform.getOpening():\n
+ if len(person_list) == 0:\n
+ person = person_module.newContent(portal_type=\'Person\')\n
+ person.edit(\n
+ first_name = request_eform.getFirstName(),\n
+ last_name = request_eform.getLastName(),\n
+ default_address_street_address = request_eform.getHeadOfficeAddress(),\n
+ start_date = request_eform.getStartDate(),\n
+ default_birthplace_address_city = request_eform.getDefaultBirthplaceAddressCity(),\n
+ default_address_city = request_eform.getPlace(),\n
+ nationality = request_eform.getCitizenship().lower())\n
+ # Update matrimonial situation for the person\n
+ if request_eform.getMarriedCheck():\n
+ person.edit(marital_status = \'married\')\n
+ elif request_eform.getDivorcedCheck():\n
+ person.edit(marital_status = \'divorced\')\n
+ elif request_eform.getSingleCheck():\n
+ person.edit(marital_status = \'single\')\n
+ elif request_eform.getWidowerCheck():\n
+ person.edit(marital_status = \'widowed\')\n
+ if request_eform.getMrCheck():\n
+ person.edit(gender = \'male\')\n
+ else:\n
+ person.edit(gender = \'female\')\n
+\n
+ else: # person exists\n
+ if len(person_list) >1 :\n
+ raise ValidationFailed, "Error : There is more than one person with the "\\\n
+ " title \'%s\', birth date \'%s\' and birthplace \'%s\'" % (request_eform.getTitle(),\n
+ request_eform.getStartDate(),\n
+ request_eform.getDefaultBirthplaceAddressCity())\n
+ elif len(person_list) == 0:\n
+ raise ValidationFailed, "Error : There is nobody with the "\\\n
+ " title \'%s\', birth date \'%s\' and birthplace \'%s\'" % (request_eform.getTitle(),\n
+ request_eform.getStartDate(),\n
+ request_eform.getDefaultBirthplaceAddressCity())\n
+ else:\n
+ person = person_list[0]\n
+\n
+ # add a new assignment to this person\n
+ assignment = person.newContent(portal_type=\'Assignment\',\n
+ function=\'commerce/commercant\',\n
+ start_date=request_eform.getBeginningDate(),\t\n
+ destination_form_value=request_eform,\n
+ destination_value=organisation)\n
+ assignment.openSubmit()\n
+ assignment.open()\n
+ person.updateLocalRolesOnSecurityGroups()\n
\n
# In case of an harmonisation, update the organisation corporate_registration_code with the old corporate_registration_code\n
#used to create the organisation\n
@@ -179,10 +201,16 @@
organisation.edit(corporate_registration_code = request_eform.getCorporateRegistrationCode(),\n
geographic_incorporate_code = \'-\'.join(str(request_eform.getCorporateRegistrationCode()).split(\'-\')[0:2])\n
)\n
-else:\n
+elif not request_eform.getActivityRestartCheck():\n
organisation.edit(corporate_registration_code = new_registry_number,\n
geographic_incorporate_code = \'-\'.join(str(new_registry_number).split(\'-\')[0:2])\n
)\n
+\n
+# In case of opening a secondary establishment, the main company rccm number\n
+# have to be saved in source_reference variable \n
+if request_eform.getOpening():\n
+ organisation.setSourceReference(request_eform.getPreviousOwnerCorporateRegistrationCode())\n
+\n
organisation.activerEntreprise()\n
organisation.updateLocalRolesOnSecurityGroups()\n
# Update the request_eform with the allocated number\n
@@ -252,13 +280,19 @@
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>ComplexQuery</string>
<string>Query</string>
+ <string>Products.DCWorkflow.DCWorkflow</string>
+ <string>ValidationFailed</string>
<string>_getitem_</string>
<string>request_eform</string>
<string>_getattr_</string>
<string>portal</string>
<string>person_module</string>
<string>organisation_module</string>
+ <string>None</string>
<string>organisation</string>
+ <string>rccm</string>
+ <string>organisation_list</string>
+ <string>len</string>
<string>date</string>
<string>attachLocationYearInfo</string>
<string>new_registry_number</string>
@@ -268,8 +302,6 @@
<string>_getiter_</string>
<string>person</string>
<string>person_list</string>
- <string>len</string>
- <string>ValidationFailed</string>
<string>assignment</string>
<string>str</string>
<string>history_list</string>
Modified: erp5/trunk/bt5/erp5_registry_ohada/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_registry_ohada/bt/revision?rev=22994&r1=22993&r2=22994&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_registry_ohada/bt/revision (original)
+++ erp5/trunk/bt5/erp5_registry_ohada/bt/revision Thu Aug 14 12:18:20 2008
@@ -1,1 +1,1 @@
-893
+900
More information about the Erp5-report
mailing list