diff --git a/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/createPersonFromP0.xml b/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/createPersonFromP0.xml index 6e711616bd1690de462d2d62003d28c001ee2801..be3b319fd581372c34ac9c81418f5e0a65bc40eb 100644 --- a/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/createPersonFromP0.xml +++ b/bt5/erp5_registry_ohada/WorkflowTemplateItem/portal_workflow/ohada_form_validation_interaction_workflow/scripts/createPersonFromP0.xml @@ -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 - 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=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 - 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 +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 + 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 + # 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 @@ 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> diff --git a/bt5/erp5_registry_ohada/bt/revision b/bt5/erp5_registry_ohada/bt/revision index 9c574c95386ccbd814a27b1a634f4169bad6c734..8ffdba9a31b940d81f3d1bcf142c4955d7c5ac8b 100644 --- a/bt5/erp5_registry_ohada/bt/revision +++ b/bt5/erp5_registry_ohada/bt/revision @@ -1 +1 @@ -893 \ No newline at end of file +900 \ No newline at end of file