Commit e6fb20ab authored by Rafael Monnerat's avatar Rafael Monnerat

Validate document instead use after_script.

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