Commit 3ffda553 authored by Rafael Monnerat's avatar Rafael Monnerat

Clean up and drop workarround on PersonConfiguratorItem.

The objects are always created, so it is not required to
check if transition is possible.
parent d7fd8b84
...@@ -66,28 +66,23 @@ class PersonConfiguratorItem(XMLObject, ConfiguratorItemMixin): ...@@ -66,28 +66,23 @@ class PersonConfiguratorItem(XMLObject, ConfiguratorItemMixin):
site_id = getattr(aq_base(self), 'site_id', None) site_id = getattr(aq_base(self), 'site_id', None)
if getattr(aq_base(self), 'organisation_id', None) is not None: if getattr(aq_base(self), 'organisation_id', None) is not None:
person.setCareerSubordination('organisation_module/%s' %self.organisation_id) person.setCareerSubordination('organisation_module/%s' % \
self.organisation_id)
# save # save
person_dict = {'default_email_text': self.getDefaultEmailText(), person.edit(**{'default_email_text': self.getDefaultEmailText(),
'default_telephone_text': self.getDefaultTelephoneText(), 'default_telephone_text': self.getDefaultTelephoneText(),
'first_name': self.getFirstName(), 'first_name': self.getFirstName(),
'career_function': self.getFunction(), 'career_function': self.getFunction(),
'last_name': self.getLastName(), 'last_name': self.getLastName(),
'reference': self.getReference(),
'password': self.getPassword(), 'password': self.getPassword(),
} })
person.edit(**person_dict)
# explicitly use direct mutator to avoid uniqueness checks in Person.setReference assignment = person.newContent(portal_type="Assignment",
# which work in main ERP5 site context (uses catalog and cache) function = self.getFunction(),
# this is a problem when customer's entered reference is the same as group = group_id,
# already exisitng one in main ERP5 site one site = site_id)
person._setReference(self.getReference())
assignment = person.newContent(portal_type="Assignment")
assignment.setFunction(self.getFunction())
assignment.setGroup(group_id)
assignment.setSite(site_id)
# Set dates are required to create valid assigments. # Set dates are required to create valid assigments.
now = DateTime() now = DateTime()
...@@ -96,11 +91,8 @@ class PersonConfiguratorItem(XMLObject, ConfiguratorItemMixin): ...@@ -96,11 +91,8 @@ class PersonConfiguratorItem(XMLObject, ConfiguratorItemMixin):
# Define valid for 10 years. # Define valid for 10 years.
assignment.setStopDate(now + (365*10)) assignment.setStopDate(now + (365*10))
# Validate the Person if possible # Validate the Person and Assigment
if self.portal_workflow.isTransitionPossible(person, 'validate'):
person.validate(comment="Validated by Configurator") person.validate(comment="Validated by Configurator")
if self.portal_workflow.isTransitionPossible(assignment, 'open'):
assignment.open(comment="Open by Configuration") assignment.open(comment="Open by Configuration")
## add to customer template ## add to customer template
......
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