Commit 4daf6e24 authored by Fabien Morin's avatar Fabien Morin

update createPersonFromP0 workflow script to be able to works in all cases...

update createPersonFromP0 workflow script to be able to works in all cases (depending on checkboxes)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22994 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 086093ca
...@@ -74,16 +74,37 @@ request_eform and creates a new Person record and an organisation for this perso ...@@ -74,16 +74,37 @@ request_eform and creates a new Person record and an organisation for this perso
# Initalize some useful variables\n # Initalize some useful variables\n
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery\n from Products.ZSQLCatalog.SQLCatalog import ComplexQuery\n
from Products.ZSQLCatalog.SQLCatalog import Query\n from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n
request_eform = state_change[\'object\']\n request_eform = state_change[\'object\']\n
portal = request_eform.getPortalObject()\n portal = request_eform.getPortalObject()\n
person_module = portal.person_module\n person_module = portal.person_module\n
organisation_module = portal.organisation_module\n organisation_module = portal.organisation_module\n
organisation = organisation_module.newContent(portal_type=\'Organisation\')\n organisation = None\n
organisation.edit(role = \'commerce/siege\',\n if not request_eform.getActivityRestartCheck():\n
title = request_eform.getLogo(),\n organisation = organisation_module.newContent(portal_type=\'Organisation\')\n
corporate_name = request_eform.getLogo(),\n organisation.edit(title = request_eform.getLogo(),\n
activity_free_text = request_eform.getMainActivityFreeText(),\n corporate_name = request_eform.getLogo(),\n
default_address_street_address = request_eform.getRealAddress())\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 date = request_eform.getDate()\n
# Create a new person based on eform data\n # Create a new person based on eform data\n
# we suppose here that all data in the form has\n # we suppose here that all data in the form has\n
...@@ -125,53 +146,54 @@ query=ComplexQuery(Query(title=request_eform.getTitle()),\n ...@@ -125,53 +146,54 @@ query=ComplexQuery(Query(title=request_eform.getTitle()),\n
Query(birthplace_city=request_eform.getDefaultBirthplaceAddressCity()),\n Query(birthplace_city=request_eform.getDefaultBirthplaceAddressCity()),\n
operator="AND")\n operator="AND")\n
person_list = [person.getObject() for person in person_module.searchFolder(query=query)]\n person_list = [person.getObject() for person in person_module.searchFolder(query=query)]\n
if len(person_list) == 0:\n if request_eform.getBeginning() or request_eform.getOpening():\n
person = person_module.newContent(portal_type=\'Person\')\n if len(person_list) == 0:\n
person.edit(\n person = person_module.newContent(portal_type=\'Person\')\n
first_name = request_eform.getFirstName(),\n person.edit(\n
last_name = request_eform.getLastName(),\n first_name = request_eform.getFirstName(),\n
default_address_street_address = request_eform.getHeadOfficeAddress(),\n last_name = request_eform.getLastName(),\n
start_date = request_eform.getStartDate(),\n default_address_street_address = request_eform.getHeadOfficeAddress(),\n
default_birthplace_address_city = request_eform.getDefaultBirthplaceAddressCity(),\n start_date = request_eform.getStartDate(),\n
default_address_city = request_eform.getPlace(),\n default_birthplace_address_city = request_eform.getDefaultBirthplaceAddressCity(),\n
nationality = request_eform.getCitizenship().lower())\n default_address_city = request_eform.getPlace(),\n
# Update matrimonial situation for the person\n nationality = request_eform.getCitizenship().lower())\n
if request_eform.getMarriedCheck():\n # Update matrimonial situation for the person\n
person.edit(marital_status = \'married\')\n if request_eform.getMarriedCheck():\n
elif request_eform.getDivorcedCheck():\n person.edit(marital_status = \'married\')\n
person.edit(marital_status = \'divorced\')\n elif request_eform.getDivorcedCheck():\n
elif request_eform.getSingleCheck():\n person.edit(marital_status = \'divorced\')\n
person.edit(marital_status = \'single\')\n elif request_eform.getSingleCheck():\n
elif request_eform.getWidowerCheck():\n person.edit(marital_status = \'single\')\n
person.edit(marital_status = \'widowed\')\n elif request_eform.getWidowerCheck():\n
if request_eform.getMrCheck():\n person.edit(marital_status = \'widowed\')\n
person.edit(gender = \'male\')\n if request_eform.getMrCheck():\n
else:\n person.edit(gender = \'male\')\n
person.edit(gender = \'female\')\n else:\n
person.edit(gender = \'female\')\n
\n \n
else: # person exists\n else: # person exists\n
if len(person_list) >1 :\n if len(person_list) >1 :\n
raise ValidationFailed, "Error : There is more than one person with the "\\\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 " title \'%s\', birth date \'%s\' and birthplace \'%s\'" % (request_eform.getTitle(),\n
request_eform.getStartDate(),\n request_eform.getStartDate(),\n
request_eform.getDefaultBirthplaceAddressCity())\n request_eform.getDefaultBirthplaceAddressCity())\n
elif len(person_list) == 0:\n elif len(person_list) == 0:\n
raise ValidationFailed, "Error : There is nobody with the "\\\n raise ValidationFailed, "Error : There is nobody with the "\\\n
" title \'%s\', birth date \'%s\' and birthplace \'%s\'" % (request_eform.getTitle(),\n " title \'%s\', birth date \'%s\' and birthplace \'%s\'" % (request_eform.getTitle(),\n
request_eform.getStartDate(),\n request_eform.getStartDate(),\n
request_eform.getDefaultBirthplaceAddressCity())\n request_eform.getDefaultBirthplaceAddressCity())\n
else:\n else:\n
person = person_list[0]\n person = person_list[0]\n
\n \n
# add a new assignment to this person\n # add a new assignment to this person\n
assignment = person.newContent(portal_type=\'Assignment\',\n assignment = person.newContent(portal_type=\'Assignment\',\n
function=\'commerce/commercant\',\n function=\'commerce/commercant\',\n
start_date=request_eform.getBeginningDate(),\t\n start_date=request_eform.getBeginningDate(),\t\n
destination_form_value=request_eform,\n destination_form_value=request_eform,\n
destination_value=organisation)\n destination_value=organisation)\n
assignment.openSubmit()\n assignment.openSubmit()\n
assignment.open()\n assignment.open()\n
person.updateLocalRolesOnSecurityGroups()\n person.updateLocalRolesOnSecurityGroups()\n
\n \n
# In case of an harmonisation, update the organisation corporate_registration_code with the old corporate_registration_code\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 #used to create the organisation\n
...@@ -179,10 +201,16 @@ if not request_eform.getBeginning() and not request_eform.getActivityRestartChec ...@@ -179,10 +201,16 @@ if not request_eform.getBeginning() and not request_eform.getActivityRestartChec
organisation.edit(corporate_registration_code = request_eform.getCorporateRegistrationCode(),\n organisation.edit(corporate_registration_code = request_eform.getCorporateRegistrationCode(),\n
geographic_incorporate_code = \'-\'.join(str(request_eform.getCorporateRegistrationCode()).split(\'-\')[0:2])\n geographic_incorporate_code = \'-\'.join(str(request_eform.getCorporateRegistrationCode()).split(\'-\')[0:2])\n
)\n )\n
else:\n elif not request_eform.getActivityRestartCheck():\n
organisation.edit(corporate_registration_code = new_registry_number,\n organisation.edit(corporate_registration_code = new_registry_number,\n
geographic_incorporate_code = \'-\'.join(str(new_registry_number).split(\'-\')[0:2])\n geographic_incorporate_code = \'-\'.join(str(new_registry_number).split(\'-\')[0:2])\n
)\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.activerEntreprise()\n
organisation.updateLocalRolesOnSecurityGroups()\n organisation.updateLocalRolesOnSecurityGroups()\n
# Update the request_eform with the allocated number\n # Update the request_eform with the allocated number\n
...@@ -252,13 +280,19 @@ for history in history_list:\n ...@@ -252,13 +280,19 @@ for history in history_list:\n
<string>Products.ZSQLCatalog.SQLCatalog</string> <string>Products.ZSQLCatalog.SQLCatalog</string>
<string>ComplexQuery</string> <string>ComplexQuery</string>
<string>Query</string> <string>Query</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>request_eform</string> <string>request_eform</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>portal</string> <string>portal</string>
<string>person_module</string> <string>person_module</string>
<string>organisation_module</string> <string>organisation_module</string>
<string>None</string>
<string>organisation</string> <string>organisation</string>
<string>rccm</string>
<string>organisation_list</string>
<string>len</string>
<string>date</string> <string>date</string>
<string>attachLocationYearInfo</string> <string>attachLocationYearInfo</string>
<string>new_registry_number</string> <string>new_registry_number</string>
...@@ -268,8 +302,6 @@ for history in history_list:\n ...@@ -268,8 +302,6 @@ for history in history_list:\n
<string>_getiter_</string> <string>_getiter_</string>
<string>person</string> <string>person</string>
<string>person_list</string> <string>person_list</string>
<string>len</string>
<string>ValidationFailed</string>
<string>assignment</string> <string>assignment</string>
<string>str</string> <string>str</string>
<string>history_list</string> <string>history_list</string>
......
893 900
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment