Commit e6fb20ab authored by Rafael Monnerat's avatar Rafael Monnerat

Validate document instead use after_script.

parent c5c71bee
......@@ -75,5 +75,8 @@ class AccountConfiguratorItem(ConfiguratorItemMixin, XMLObject):
description=self.getDescription(),
**extra_kw)
if self.portal_workflow.isTransitionPossible(account, 'validate'):
account.validate(comment="Validated by Configurator")
## add to customer template
self.install(account, business_configuration)
......@@ -60,11 +60,15 @@ class AccountingPeriodConfiguratorItem(ConfiguratorItemMixin, XMLObject):
organisation_id = business_configuration.\
getGlobalConfigurationAttr('organisation_id')
organisation = portal.organisation_module._getOb(organisation_id)
organisation.newContent(portal_type='Accounting Period',
period = organisation.newContent(
portal_type='Accounting Period',
start_date=self.getStartDate(),
stop_date=self.getStopDate(),
short_title=self.getShortTitle(),
title=self.getTitle())
if self.portal_workflow.isTransitionPossible(period, 'start'):
period.start(comment="Started by Configurator")
# no need to 'install' in the business template, because it's contain as
# subobject of an organisation we already added.
......@@ -77,5 +77,8 @@ class OrganisationConfiguratorItem(ConfiguratorItemMixin, XMLObject):
# store globally organization_id
business_configuration.setGlobalConfigurationAttr(organisation_id=organisation.getId())
if self.portal_workflow.isTransitionPossible(organisation, 'validate'):
organisation.validate(comment="Validated by Configurator")
## add to customer template
self.install(organisation, business_configuration)
......@@ -95,6 +95,13 @@ class PersonConfiguratorItem(XMLObject, ConfiguratorItemMixin):
# XXX Is it required to set stop date?
# Define valid for 10 years.
assignment.setStopDate(now + (365*10))
# Validate the Person if possible
if self.portal_workflow.isTransitionPossible(person, 'validate'):
person.validate(comment="Validated by Configurator")
if self.portal_workflow.isTransitionPossible(assignment, 'open'):
assignment.open(comment="Open by Configuration")
## add to customer template
self.install(person, business_configuration)
......@@ -110,6 +110,10 @@ class PreferenceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
if preference_value is not marker:
preference_dict[preference_name] = preference_value
if self.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
organisation_id = business_configuration.\
preference_dict['preferred_accounting_transaction_source_section'] = \
organisation_path
preference_dict['preferred_section'] = organisation_path
......
......@@ -82,4 +82,6 @@ class PurchaseTradeConditionConfiguratorItem(ConfiguratorItemMixin, XMLObject):
purchase_trade_condition.setDestinationSection("organisation_module/%s" % organisation_id)
purchase_trade_condition.setPriceCurrency("currency_module/%s" % currency_id)
purchase_trade_condition.validate(comment="Validated by Configurator")
self.install(purchase_trade_condition, business_configuration)
......@@ -82,4 +82,6 @@ class SaleTradeConditionConfiguratorItem(ConfiguratorItemMixin, XMLObject):
sale_trade_condition.setSourceSection("organisation_module/%s" % organisation_id)
sale_trade_condition.setPriceCurrency("currency_module/%s" % currency_id)
sale_trade_condition.validate(comment="Validated by Configurator")
self.install(sale_trade_condition, business_configuration)
......@@ -61,7 +61,8 @@ class ServiceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
document = getattr(portal.service_module, service_id, None)
if document is None:
document = portal.service_module.newContent(portal_type='Service',
id=service_id,
title=service_title)
id=service_id, title=service_title)
document.validate("Validated by Configurator")
## add to customer template
self.install(document, business_configuration)
......@@ -66,9 +66,28 @@ class StandardBT5ConfiguratorItem(ConfiguratorItemMixin, XMLObject):
template_tool.installBusinessTemplateListFromRepository([bt5_id],
update_catalog=self.getUpdateCatalog(0))
LOG("StandardBT5ConfiguratorItem", INFO,
"Install %s for %s" % (bt5_id, self.getRelativeUrl()))
return
if bt5_id in template_tool.getInstalledBusinessTemplateTitleList():
LOG("StandardBT5ConfiguratorItem", INFO,
"Business Template already Installed: %s for %s" % (bt5_id, self.getRelativeUrl()))
return
def _getRepositoryBusinessTemplateTitleList():
return [bt.getTitle() for bt in \
template_tool.getRepositoryBusinessTemplateList()]
repository_bt_title_list = CachingMethod(
_getRepositoryBusinessTemplateTitleList,
id='StandardBT5_getRepositoryBusinessTemplateTitleList',
cache_factory='erp5_content_long')()
if bt5_id in repository_bt_title_list:
template_tool.installBusinessTemplateListFromRepository([bt5_id],
update_catalog=self.getUpdateCatalog(0),
install_dependency=self.getInstallDependency(1),
activate=True)
LOG("StandardBT5ConfiguratorItem", INFO,
"Install %s for %s" % (bt5_id, self.getRelativeUrl()))
return
raise ValueError("The business template %s was not found on available \
sources." % bt5_id)
......
......@@ -110,6 +110,8 @@ class SystemPreferenceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
# XXX this have to be translated in user language.
preference_dict = {}
marker = []
activated_preference = portal.portal_preferences.getActiveSystemPreference()
for preference_name in self._getPreferenceNameList():
preference_value = getattr(self, preference_name,
preference.getProperty(preference_name))
......@@ -117,6 +119,9 @@ class SystemPreferenceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
preference_value = activated_preference.getProperty(preference_name)
preference_dict[preference_name] = preference_value
if self.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
preference.edit(**preference_dict)
bt5_obj = business_configuration.getSpecialiseValue()
current_template_preference_list = list(bt5_obj.getTemplatePreferenceList())
......
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