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
# 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
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,7 +146,8 @@ query=ComplexQuery(Query(title=request_eform.getTitle()),\n
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
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
......@@ -149,7 +171,7 @@ if len(person_list) == 0:\n
else:\n
person.edit(gender = \'female\')\n
\n
else: # person exists\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
......@@ -163,15 +185,15 @@ else: # person exists\n
else:\n
person = person_list[0]\n
\n
# add a new assignment to this person\n
assignment = person.newContent(portal_type=\'Assignment\',\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
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 @@ if not request_eform.getBeginning() and not request_eform.getActivityRestartChec
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 @@ for history in history_list:\n
<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 @@ for history in history_list:\n
<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>
......
893
\ No newline at end of file
900
\ 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