Commit dc26ced4 authored by Rafael Monnerat's avatar Rafael Monnerat

ERP5 Configurator Product initial commit.

ERP5 Configurator allows developer creates configuration wizards for configure an ERP5 Instance. 


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41680 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c12fa76d
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class AccountConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" Setup an Accounting Account. """
meta_type = 'ERP5 Account Configurator Item'
portal_type = 'Account Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Account )
def build(self, business_configuration):
portal = self.getPortalObject()
account_module = portal.account_module
extra_kw = {}
account_id = getattr(self, 'account_id', None)
if account_id:
# XXX FIXME This cause conflict when use configuration
# more then once.
#extra_kw['id'] = account_id
pass
account = account_module.newContent(
portal_type='Account',
title=self.getTitle(),
account_type=self.getAccountType(),
gap=self.getGap(),
financial_section=self.getFinancialSection(),
credit_account=self.isCreditAccount(),
description=self.getDescription(),
**extra_kw)
## add to customer template
self.install(account, business_configuration)
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# Jerome Perrin <jerome@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class AccountingPeriodConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" Setup an Accounting Period. """
meta_type = 'ERP5 Accounting Period Configurator Item'
portal_type = 'Accounting Period Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Task )
def build(self, business_configuration):
portal = self.getPortalObject()
organisation_id = business_configuration.\
getGlobalConfigurationAttr('organisation_id')
organisation = portal.organisation_module._getOb(organisation_id)
period = organisation.newContent(
portal_type='Accounting Period',
start_date=self.getStartDate(),
stop_date=self.getStopDate(),
short_title=self.getShortTitle(),
title=self.getTitle())
# no need to 'install' in the business template, because it's contain as
# subobject of an organisation we already added.
This diff is collapsed.
##############################################################################
#
# Copyright (c) 2008 Nexedi SARL and Contributors. All Rights Reserved.
# Yoshinori Okuji <yo@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class CatalogKeywordKeyConfiguratorItem(ConfiguratorItemMixin, XMLObject):
"""Set up catalog keyword keys."""
meta_type = 'ERP5 Catalog Keyword Key Configurator Item'
portal_type = 'Catalog Keyword Key Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def build(self, business_configuration):
portal = self.getPortalObject()
catalog = portal.portal_catalog.getSQLCatalog()
key_list = list(catalog.getProperty('sql_catalog_keyword_search_keys', ()))
for k in self.key_list:
if k not in key_list:
key_list.append(k)
key_list = tuple(key_list)
catalog._setPropValue('sql_catalog_keyword_search_keys', key_list)
bt = business_configuration.getSpecialiseValue()
bt.edit(template_catalog_keyword_key_list=key_list)
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# Jerome Perrin <jerome@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from StringIO import StringIO
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class UnrestrictedStringIO(StringIO):
__allow_access_to_unprotected_subobjects__ = 1
class CategoriesSpreadsheetConfiguratorItem(ConfiguratorItemMixin, XMLObject):
"""Import a categories spreadsheet.
"""
meta_type = 'ERP5 Categories Spreadsheet Configurator Item'
portal_type = 'Categories Spreadsheet Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.CategoriesSpreadsheetConfiguratorItem
)
def build(self, business_configuration):
portal = self.getPortalObject()
ctool = portal.portal_categories
self._readSpreadSheet()
cache = self._category_cache
for bc_id, category_list in cache.items():
if bc_id in ctool.objectIds():
bc = ctool._getOb(bc_id)
else:
# TODO: test bc creation
# the bc should be added as base category in bt5 ?
bc = ctool.newContent(id=bc_id)
for category_info in category_list:
path = bc
for cat in category_info['path'].split("/")[1:]:
if not cat in path.objectIds():
path = path.newContent(
portal_type='Category',
id=cat,)
else:
path = path[cat]
edit_dict = category_info.copy()
edit_dict.pop('path')
path.edit(**edit_dict)
## add to customer template
self.install(path, business_configuration)
def _readSpreadSheet(self):
"""Read the spreadsheet and prepare internal category cache.
"""
aq_self = aq_base(self)
if getattr(aq_self, '_category_cache', None) is None:
# TODO use a invalid_spreadsheet_error_handler to report invalid
# spreadsheet messages (see http://svn.erp5.org?rev=24908&view=rev )
aq_self._category_cache = self.Base_getCategoriesSpreadSheetMapping(
UnrestrictedStringIO(self.getDefaultCategoriesSpreadsheetData()))
security.declareProtected(Permissions.ModifyPortalContent,
'setDefaultCategoriesSpreadsheetFile')
def setDefaultCategoriesSpreadsheetFile(self, *args, **kw):
"""Reset the spreadsheet cache."""
self._setDefaultCategoriesSpreadsheetFile(*args, **kw)
self._category_cache = None
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent,
'setCategoriesSpreadsheetFile')
setCategoriesSpreadsheetFile = setDefaultCategoriesSpreadsheetFile
security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryTitleItemList')
def getCategoryTitleItemList(self, base_category_id, base=0):
"""Returns title item list for a base category contained in this
spreadsheet.
"""
self._readSpreadSheet()
cache = self._category_cache
result = [('', '')]
if base_category_id not in cache:
return result # TODO: return some kind of default. Where is this
# default ??? configurator_%s % base_category_id ?
# If we add default here, it should also be used in build
# ...
category_path_dict = dict()
for item in cache[base_category_id]:
category_path_dict[item['path']] = item
for item in cache[base_category_id]:
# the first item in this list is the base category itself, so we skip it.
if item['path'] == base_category_id:
continue
# recreate logical path
path_element_list = []
title_list = []
for path_element in item['path'].split('/'):
path_element_list.append(path_element)
title_list.append(category_path_dict['/'.join(path_element_list)]['title'])
if base:
result.append(('/'.join(title_list[1:]), item['path']))
else:
result.append(('/'.join(title_list[1:]),
'/'.join(item['path'].split('/')[1:])))
return result
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class CategoryConfiguratorItem(ConfiguratorItemMixin, XMLObject):
"""This class is meta build step for customization of ERP5 site."""
meta_type = 'ERP5 Category Configurator Item'
portal_type = 'Category Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore)
def build(self, business_configuration):
portal = self.getPortalObject()
category_root = portal.portal_categories[self.category_root]
object_id = self.object_id
if object_id in category_root.objectIds():
category_root.manage_delObjects(object_id)
category = category_root.newContent(portal_type='Category',
id = object_id,
title = self.getTitle())
## add to customer template
self.install(category, business_configuration)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com>
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Path import Path
class ConfigurationSave(Path):
""" This class is the base class for all template items. """
portal_type = 'Configuration Save'
meta_type = 'ERP5 Configuration Save'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.SortIndex )
def addConfigurationItem(self, configuration_item_class_name, **kw):
""" Add new configuration item. """
## remove manually specified a configration title
if kw.has_key('conf_title'):
self.setTitle(kw['conf_title'])
kw.pop('conf_title')
conf_item = self.newContent(portal_type = configuration_item_class_name, **kw)
return conf_item
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class CurrencyConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" Setup currency. """
meta_type = 'ERP5 Currency Configurator Item'
portal_type = 'Currency Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Price
, PropertySheet.Resource
, PropertySheet.Reference )
def build(self, business_configuration):
portal = self.getPortalObject()
currency_module = portal._getOb('currency_module')
title = self.getTitle()
reference = self.getReference()
base_unit_quantity = self.getBaseUnitQuantity()
# XXX FIXME This is not exactly desired behaviour
currency = self.portal_catalog.getResultValue(id=reference,
portal_type="Currency")
if currency is None:
currency = currency_module.newContent(portal_type = "Currency",
id = reference,
title = title,
reference = reference,
base_unit_quantity = base_unit_quantity)
## add to customer template
self.install(currency, business_configuration)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.CMFCore.utils import getToolByName
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class CustomerBT5ConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" Create a new bt5 for customer configuration.
This business template is not installed locally, only build.
"""
meta_type = 'ERP5 Customer BT5 Configurator Item'
portal_type = 'Customer BT5 Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def build(self, business_configuration):
template_tool = getToolByName(self.getPortalObject(),
'portal_templates')
bt5 = template_tool.newContent(portal_type="Business Template", \
title=self.bt5_id)
## ..and set it as current
business_configuration.setSpecialise(bt5.getRelativeUrl())
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.CMFCore.utils import getToolByName
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class ExportCustomerBT5ConfiguratorItem(XMLObject, ConfiguratorItemMixin):
""" Create a new bt5 for customer configuration. """
meta_type = 'ERP5 Export Customer BT5 Configurator Item'
portal_type = 'Export Customer BT5 Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def build(self, business_configuration):
portal = self.getPortalObject()
template_tool = getToolByName(portal, 'portal_templates')
bt5_obj = business_configuration.getSpecialiseValue()
if bt5_obj.getBuildingState() != 'built':
## build template so it can be exported
bt5_obj.edit()
bt5_obj.build()
bt5_data = template_tool.export(bt5_obj)
business_configuration.newContent(
portal_type='File',
title = bt5_obj.getTitle(),
data = bt5_data)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class OrganisationConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" This class install a Organisation."""
meta_type = 'ERP5 Organisation Configurator Item'
portal_type = 'Organisation Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Organisation )
def build(self, business_configuration):
""" Setup organisation. """
portal = self.getPortalObject()
organisation = portal.organisation_module.newContent(portal_type="Organisation")
org_dict = {'price_currency': 'currency_module/%s' % self.getPriceCurrency(),
'group': self.getGroup(),
'title': self.getTitle(),
'corporate_name': self.getCorporateName(),
'default_address_city': self.getDefaultAddressCity(),
'default_email_text': self.getDefaultEmailText(),
'default_telephone_text': self.getDefaultTelephoneText(),
'default_address_zip_code': self.getDefaultAddressZipCode(),
'default_address_region': self.getDefaultAddressRegion(),
'default_address_street_address': self.getDefaultAddressStreetAddress(),
'site':'main', # First customer's organisation is always main site.
}
organisation.edit(**org_dict)
# store globally organization_id
business_configuration.setGlobalConfigurationAttr(organisation_id=organisation.getId())
## add to customer template
self.install(organisation, business_configuration)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class PermissionConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" Set permission matrix on module."""
meta_type = 'ERP5 Permission Configurator Item'
portal_type = 'Permission Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def build(self, business_configuration):
template_module_id_list = []
module_permissions_map = {}
sheets_dict = business_configuration.ConfigurationTemplate_readOOCalcFile(\
self.filename)
for module_id, permissions in sheets_dict.items():
module_permissions = {}
for permission in permissions:
roles = []
permission_name = permission.pop('permission')
for role, checked in permission.items():
if checked == '1': roles.append(role)
module_permissions[permission_name] = roles
# add to module map
module_permissions_map[module_id] = module_permissions
# set permissions in fake site
portal = self.getPortalObject()
for module_id, permissions_map in module_permissions_map.items():
if permissions_map != {}:
template_module_id_list.append(module_id)
module = portal[module_id]
for permission_name, roles in permissions_map.items():
# we must alway include additionally 'Manager' and 'Owner'
roles.extend(['Manager', 'Owner'])
module.manage_permission(permission_name, tuple(roles), 0)
# add customized module to customer's bt5
if len(template_module_id_list):
bt5_obj = business_configuration.getSpecialiseValue()
bt5_obj.setTemplateModuleIdList(template_module_id_list)
\ No newline at end of file
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from DateTime import DateTime
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class PersonConfiguratorItem(XMLObject, ConfiguratorItemMixin):
""" Setup user. """
meta_type = 'ERP5 Person Configurator Item'
portal_type = 'Person Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Reference
, PropertySheet.Person
, PropertySheet.Login)
def build(self, business_configuration):
portal = self.getPortalObject()
person = portal.person_module.newContent(portal_type="Person")
group_id = getattr(aq_base(self), 'group_id', None)
site_id = getattr(aq_base(self), 'site_id', None)
if getattr(aq_base(self), 'organisation_id', None) is not None:
person.setCareerSubordination('organisation_module/%s' %self.organisation_id)
# save
person_dict = {'default_email_text': self.getDefaultEmailText(),
'default_telephone_text': self.getDefaultTelephoneText(),
'first_name': self.getFirstName(),
'career_function': self.getFunction(),
'last_name': self.getLastName(),
'password': self.getPassword(),
}
person.edit(**person_dict)
# explicitly use direct mutator to avoid uniqueness checks in Person.setReference
# which work in main ERP5 site context (uses catalog and cache)
# this is a problem when customer's entered reference is the same as
# already exisitng one in main ERP5 site one
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.
now = DateTime()
assignment.setStartDate(now)
# XXX Is it required to set stop date?
# Define valid for 10 years.
assignment.setStopDate(now + (365*10))
## add to customer template
self.install(person, business_configuration)
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# TAHARA Yusei <yusei@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class PortalTypeConfiguratorItem(ConfiguratorItemMixin, XMLObject):
"""Configure Portal Type."""
meta_type = 'ERP5 Portal Type Configurator Item'
portal_type = 'Portal Type Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def build(self, business_configuration):
portal = self.getPortalObject()
# Support adding new property sheet to portal type information.
# arguments:
# * target_portal_type
# * add_propertysheet_list
type_information = getattr(portal.portal_types, self.target_portal_type)
for name in self.add_propertysheet_list:
if not name in type_information.property_sheet_list:
new_property_sheet_list = list(type_information.property_sheet_list)
new_property_sheet_list.append(name)
type_information.property_sheet_list = tuple(new_property_sheet_list)
bt5_obj = business_configuration.getSpecialiseValue()
old_property_sheet_list = bt5_obj.getTemplatePortalTypePropertySheetList()
new_property_sheet_list = (list(old_property_sheet_list) +
['%s | %s' % (self.target_portal_type, name)
for name in self.add_propertysheet_list]
)
bt5_obj.edit(
template_portal_type_property_sheet_list=new_property_sheet_list)
#
# TODO:This class must support many other features we can use in ZMI.
#
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# Jerome Perrin <jerome@nexedi.com>
#
##############################################################################
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class PortalTypeRolesSpreadsheetConfiguratorItem(ConfiguratorItemMixin, XMLObject):
"""Import a portal type roles spreadsheet.
"""
meta_type = 'ERP5 Portal Type Roles Spreadsheet Configurator Item'
portal_type = 'Portal Type Roles Spreadsheet Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.PortalTypeRolesSpreadsheetConfiguratorItem
)
def build(self, business_configuration):
portal = self.getPortalObject()
self._readSpreadSheet()
for type_name, role_list in self._spreadsheet_cache.items():
portal_type = portal.portal_types.getTypeInfo(type_name)
for role in role_list:
# rebuild a category from Group / Site & Function
category_list = []
for bc in ('Group', 'Site', 'Function'):
if role.get(bc):
category_list.append(role[bc])
#category = '\n'.join(category_list)
role_dict = {
#'title': 'role',
'description': role.get('Description', ''),
'role_name_list': role.get('Role'),
'role_category_list': category_list,
'role_base_category_list': role.get('Base_Category', ''),
'role_base_category_script_id': role.get('Base_Category_Script',
role.get('Script', ''))}
portal_type.newContent(portal_type='Role Information', \
**role_dict)
## Update BT5
bt5_obj = business_configuration.getSpecialiseValue()
bt5_obj.edit(template_portal_type_roles_list=self._spreadsheet_cache.keys())
def checkSpreadSheetConsistency(self):
"""Check that the spread sheet is consistent with categories spreadsheet.
- all roles have a name ('Name' or 'Role')
- all roles have a portal type ('Name' or 'Role')
- all roles uses valid group & function categories
XXX do we want to use constraint framework here ?
"""
def _readSpreadSheet(self):
"""Read the spreadsheet and prepare internal category cache.
"""
aq_self = aq_base(self)
if getattr(aq_self, '_spreadsheet_cache', None) is None:
role_dict = dict()
info_dict = self.ConfigurationTemplate_readOOCalcFile(
'default_portal_type_roles_spreadsheet')
for sheet_name, table in self.ConfigurationTemplate_readOOCalcFile(
'default_portal_type_roles_spreadsheet').items():
for line in table:
if 'Portal_Type' in line:
ptype_role_list = role_dict.setdefault(line['Portal_Type'], [])
ptype_role_list.append(line)
aq_self._spreadsheet_cache = role_dict
security.declareProtected(Permissions.ModifyPortalContent,
'setDefaultPortalTypeRolesSpreadsheetFile')
def setDefaultPortalTypeRolesSpreadsheetFile(self, *args, **kw):
"""Reset the spreadsheet cache."""
self._setDefaultPortalTypeRolesSpreadsheetFile(*args, **kw)
self._spreadsheet_cache = None
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent,
'setPortalTypeRolesSpreadsheetFile')
setPortalTypeRolesSpreadsheetFile = setDefaultPortalTypeRolesSpreadsheetFile
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class PreferenceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" Setup preference. """
meta_type = 'ERP5 Preference Configurator Item'
portal_type = 'Preference Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def _getPreferenceNameList(self):
"""Returns all existing preference names.
TODO: this should be done by introspecting property sheet.
"""
return ( 'preferred_category_child_item_list_method_id',
'preferred_accounting_transaction_from_date',
'preferred_accounting_transaction_at_date',
'preferred_section_category',
'preferred_section',
'preferred_accounting_transaction_section_category',
'preferred_accounting_transaction_source_section',
'preferred_accounting_transaction_currency',
'preferred_accounting_transaction_gap',
'preferred_accounting_transaction_simulation_state_list',
'preferred_text_format',
'preferred_text_editor',
'preferred_date_order',
'preferred_listbox_view_mode_line_count',
'preferred_listbox_list_mode_line_count',
'preferred_string_field_width',
'preferred_textarea_width',
'preferred_textarea_height',
'preferred_money_quantity_field_width',
'preferred_quantity_field_width',
'preferred_report_style',
'preferred_report_format',
'preferred_html_style_access_tab',
)
def build(self, business_configuration):
portal = self.getPortalObject()
organisation_id = business_configuration.\
getGlobalConfigurationAttr('organisation_id')
organisation_path = 'organisation_module/%s' % organisation_id
preference = portal.portal_preferences._getOb(self.object_id, None)
if preference is None:
preference = portal.portal_preferences.newContent(
portal_type='Preference',
id=self.object_id,
title = self.title,
description = self.description,
priority = 1)
# XXX this have to be translated in user language.
preference_dict = {}
marker = []
for preference_name in self._getPreferenceNameList():
preference_value = getattr(self, preference_name,
preference.getProperty(preference_name, marker))
if preference_value is not marker:
preference_dict[preference_name] = preference_value
preference_dict['preferred_accounting_transaction_source_section'] = \
organisation_path
preference_dict['preferred_section'] = organisation_path
preference.edit(**preference_dict)
bt5_obj = business_configuration.getSpecialiseValue()
current_template_preference_list = list(bt5_obj.getTemplatePreferenceList())
if preference.getId() not in current_template_preference_list:
current_template_preference_list.append(preference.getId())
bt5_obj.edit(template_preference_list=current_template_preference_list,)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
from zLOG import LOG, INFO
class RoleConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" Setup role per module basis. """
meta_type = 'ERP5 Role Configurator Item'
portal_type = 'Role Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def build(self, business_configuration):
object_list = business_configuration.ConfigurationTemplate_readOOCalcFile(self.filename)
portal = self.getPortalObject()
portal_type_dict = {}
# we may pass some override dynamic values from outside
# Example:we post 'group_id' and in column we have it then
# it will be replaced with value if not configuration file matters
dynamic_values = dict(group_id = getattr(aq_base(self), 'group_id', None),
function_id = getattr(aq_base(self), 'function_id', None),
site_id = getattr(aq_base(self), 'site_id', None),)
for oo_module_dict in object_list:
mod_conf_list = []
portal_type = oo_module_dict.pop('portal_type')
for category, role_list_string in oo_module_dict.items():
# passed from outside (it has higher priority than configuratiohn file)
category = dynamic_values.get(category, category)
title = category.replace('/', '_')
role_name_list = [x.strip() for x in role_list_string.split(';')]
role_category_list=[category]
conf_dict = {'title': title,
'description': 'Configured by Nexedi Configurator',
'role_name_list': role_name_list,
'role_category_list': role_category_list}
mod_conf_list.append(conf_dict)
portal_type_dict[portal_type] = mod_conf_list
## Update fake site
# XXX rafael: improve this, the ignore list is quite ugly.
ignore_list = []
portal_type_id_list = portal.portal_types.objectIds()
for portal_type, role_list in portal_type_dict.items():
for role_dict in role_list:
if portal_type in portal_type_id_list:
portal.portal_types[portal_type].newContent(portal_type='Role Information', \
**role_dict)
else:
ignore_list.append(portal_type)
LOG("CONFIGURATOR", INFO, "Fail to define Roles for %s" % portal_type)
## Update BT5
bt5_obj = business_configuration.getSpecialiseValue()
# keep existing roles definition (from previous configuration saves)
for existing_type in bt5_obj.getTemplatePortalTypeRolesList():
portal_type_dict[existing_type] = 1
bt5_obj.edit(template_portal_type_roles_list=[i for i in portal_type_dict.keys() if i not in ignore_list])
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Lucas Carvalho <lucas@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
from zLOG import LOG, INFO
class RuleConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" Setup Rules. """
meta_type = 'ERP5 Rule Configurator Item'
portal_type = 'Rule Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def build(self, business_configuration):
portal = self.getPortalObject()
simulation_rule_dict = portal.ERPSite_getConfiguratorSimulationRuleDict()
for key, value in simulation_rule_dict.iteritems():
reference = value.get('default_reference')
result = portal.portal_rules.searchFolder(sort_on='version',
sort_order='descending',
reference=reference)
if len(result):
value['version'] = int(result[0].getVersion()) + 1
rule = portal.portal_rules.newContent(**value)
content_list = value.pop('content_list')
for content_dict in content_list:
sub_object = rule.newContent(**content_dict)
self.install(rule, business_configuration)
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# TAHARA Yusei <yusei@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class ServiceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
"""Create default service documents."""
meta_type = 'ERP5 Service Configurator Item'
portal_type = 'Service Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.ServiceConfiguratorItem )
def build(self, business_configuration):
portal = self.getPortalObject()
module = portal.service_module
for service_id, service_title in self.getServiceList():
# XXX FIXME We cannot define service_id like this,
# because it cause conflict when configurator is
# used twice.
document = module.newContent(portal_type='Service',
#id=service_id,
title=service_title,
)
## add to customer template
self.install(document, business_configuration)
##############################################################################
#
# Copyright (c) 2008 Nexedi SARL and Contributors. All Rights Reserved.
# Yoshinori Okuji <yo@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class SitePropertyConfiguratorItem(ConfiguratorItemMixin, XMLObject):
"""Set up site properties."""
meta_type = 'ERP5 Site Property Configurator Item'
portal_type = 'Site Property Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.SitePropertyConfiguratorItem )
def build(self, business_configuration):
portal = self.getPortalObject()
id_list = []
for id, value, prop_type in self.getSitePropertyList():
if portal.hasProperty(id):
portal._delProperty(id)
portal._setProperty(id, value, type=prop_type)
id_list.append(id)
bt = business_configuration.getSpecialiseValue()
bt.edit(template_site_property_id_list=id_list)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Products.CMFCore.utils import getToolByName
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
import transaction
class StandardBT5ConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" This class will install standard ERP5 template from a repository to
fake site. """
meta_type = 'ERP5 Standard BT5 Configurator Item'
portal_type = 'Standard BT5 Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.StandardBT5ConfiguratorItem
)
def build(self, business_configuration):
bt5_id = self.getBt5Id()
bt5_copy_id = '%s_copy' % bt5_id
portal = self.getPortalObject()
template_tool = getToolByName(portal, 'portal_templates')
## Is this standard template already gzipped?
filename_bt5_id = '%s.bt5' % bt5_id
if business_configuration.isStandardBT5(filename_bt5_id):
bt_url = business_configuration.getPublicUrlForBT5Id(filename_bt5_id)
business_configuration.newContent(portal_type='Link',
url_string = bt_url, title = filename_bt5_id)
else:
## we need to make a copy of template to be able to export it
if not bt5_copy_id in template_tool.objectIds():
bt5 = template_tool.getInstalledBusinessTemplate(bt5_id)
template_copy = template_tool.manage_copyObjects(ids=(bt5.getId(),))
new_id_list = template_tool.manage_pasteObjects(template_copy)
new_bt5_id = new_id_list[0]['new_id']
template_tool.manage_renameObject(new_bt5_id, bt5_copy_id)
## we are sure that we have this business template
self._current_bt_id = bt5_copy_id
return self.get_it_built(business_configuration)
def get_it_built(self, business_configuration):
portal = self.getPortalObject()
template_tool = getToolByName(portal, 'portal_templates')
bt5_obj = self._getCurrentBT(business_configuration)
if bt5_obj.getBuildingState() != 'built':
## build template so it can be exported
bt5_obj.edit()
bt5_obj.build()
# XXX Due a bug into Business Templates it is not possible build
# the business template and export when this have one
# ActionTemplateItem. This is a TEMPORARY CHANGE and it should be
# removed as soon as Business Template is FIXED.
transaction.savepoint(optimistic=True)
bt5_data = template_tool.export(bt5_obj)
business_configuration.newContent(portal_type='File',
title = '%s.bt5' % bt5_obj.getId(),
data = bt5_data)
def _getCurrentBT(self, business_configuration):
""" Return current bt5 file. """
portal = self.getPortalObject()
template_tool = portal.portal_templates
bt5_id = self._current_bt_id
bt5_obj = portal.portal_templates[bt5_id]
return bt5_obj
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class SystemPreferenceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
"""
Setup system preference.
"""
meta_type = 'ERP5 System Preference Configurator Item'
portal_type = 'System Preference Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def _getPreferenceNameList(self):
"""Returns all existing preference names.
TODO: this should be done by introspecting property sheet.
"""
return ( # CRM
'preferred_campaign_resource_list',
'preferred_event_assessment_form_id_list',
'preferred_event_resource_list',
'preferred_event_sender_email',
'preferred_meeting_resource_list',
'preferred_sale_opportunity_resource_list',
'preferred_support_request_resource_list',
# DMS
'preferred_ooodoc_server_address',
'preferred_ooodoc_server_port_number',
'preferred_conversion_cache_factory',
'preferred_document_email_ingestion_address',
'preferred_document_reference_method_id',
'preferred_document_file_name_regular_expression',
'preferred_document_reference_regular_expression',
'preferred_document_classification',
'preferred_synchronous_metadata_discovery',
'preferred_redirect_to_document',
# PDM
'preferred_product_individual_variation_base_category_list',
'preferred_component_individual_variation_base_category_list',
'preferred_service_individual_variation_base_category_list',
# Trade
'preferred_supplier_role_list',
'preferred_client_role_list',
'preferred_sale_use_list',
'preferred_purchase_use_list',
'preferred_packing_use_list',
# Express
)
def build(self, business_configuration):
portal = self.getPortalObject()
preference = portal.portal_preferences._getOb(self.object_id, None)
if preference is None:
preference = portal.portal_preferences.newContent(
portal_type = 'System Preference',
id = self.object_id,
title = self.title,
description = self.description,
priority = 1)
# XXX this have to be translated in user language.
preference_dict = {}
marker = []
for preference_name in self._getPreferenceNameList():
preference_value = getattr(self, preference_name,
preference.getProperty(preference_name, marker))
if preference_value is not marker:
preference_dict[preference_name] = preference_value
preference.edit(**preference_dict)
bt5_obj = business_configuration.getSpecialiseValue()
current_template_preference_list = list(bt5_obj.getTemplatePreferenceList())
if preference.getId() not in current_template_preference_list:
current_template_preference_list.append(preference.getId())
bt5_obj.edit(template_preference_list=current_template_preference_list,)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Configurator.mixin.configurator_item import ConfiguratorItemMixin
class WorkflowSecurityConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" Setup workflow for different roles. Use passed OO file. """
meta_type = 'ERP5 Workflow Security Configurator Item'
portal_type = 'Workflow Security Configurator Item'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore )
def build(self, business_configuration):
## NOT TESTED
return
table_dict = business_configuration.ConfigurationTemplate_readOOCalcFile(self.filename)
portal = self.getPortalObject()
suffix = '_security'
suffix_len = len(suffix)
if self.filename[-suffix_len:] == suffix:
workflow_id = self.filename[:-suffix_len]
else:
raise "NoValidName"
# Configure state permission
view_permission_list = ['View']
access_permission_list = ['Access contents information']
modify_permission_list = ['Modify portal content']
add_content_permission_list = ['Add portal content']
# Configure list of variable on the workflow
permission_list = view_permission_list + \
access_permission_list + \
modify_permission_list + \
add_content_permission_list
# Remove permission list
workflow = portal.portal_workflow[workflow_id]
workflow.delManagedPermissions(workflow.permissions)
# Add new permission list
for permission in permission_list:
workflow.addManagedPermission(permission)
# Configure state permission matrix
state_list = table_dict['state']
for state_config in state_list:
state_id = state_config.pop('state')
state = workflow.states[state_id]
# Clean the state matrix
for permission in permission_list:
state.setPermission(permission, 0, [])
# Update state matrix
permission_dict = dict([(x, []) for x in permission_list])
for role, perm_symbol in state_config.items():
managed_permission_list = []
if 'A' in perm_symbol:
managed_permission_list.extend(access_permission_list)
if 'V' in perm_symbol:
managed_permission_list.extend(view_permission_list)
if 'C' in perm_symbol:
managed_permission_list.extend(add_content_permission_list)
if 'M' in perm_symbol:
managed_permission_list.extend(modify_permission_list)
for permission in managed_permission_list:
permission_dict[permission].append(role.capitalize())
for permission, roles in permission_dict.items():
state.setPermission(permission, 0, roles)
# XXX To be deleted
# for permission in permission_list:
# module.manage_permission(permission, ['Manager'], 0)
# Configure transition guard
transition_list = table_dict['transition']
for transition_conf in transition_list:
transition_id = transition_conf.pop('transition')
transition = workflow.transitions[transition_id]
guard = transition.getGuard()
role_list = [x.capitalize() for x in transition_conf.keys()]
role_string = ';'.join(role_list)
guard.changeFromProperties({'guard_roles': role_string})
# Update business template
bt5_obj = business_configuration.getSpecialiseValue()
template_workflow_id_list = list(bt5_obj.getTemplateWorkflowIdList())
if workflow_id not in template_workflow_id_list:
template_workflow_id_list.append(workflow_id)
bt5_obj.edit(template_workflow_id_list=template_workflow_id_list,)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com>
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import StringIO
def read(self, filename):
"""
Return a OOCalc as a StringIO
"""
oo_template_file = getattr(self, filename)
fp = StringIO.StringIO(oo_template_file)
fp.filename = filename
return fp
def getIdFromString(string):
"""
This function transform a string to a safe id.
It is used here to create a safe category id from a string.
"""
if string is None:
return None
clean_id = ''
translation_map = { "a": ['\xe0']
, "e": ['\xe9', '\xe8']
}
#string = string.lower()
string = string.strip()
# oocalc inserts some strange chars when you press - key in a text cell.
# Following line is a workaround for this,
# because \u2013 does not exist in latin1
string = string.replace(u'\u2013', '-')
for char in string.encode('utf-8'):#('iso8859_1'):
if char == '_' or char.isalnum():
clean_id += char
elif char.isspace() or char in ('+', '-'):
clean_id += '_'
else:
for (safe_char, char_list) in translation_map.items():
if char in char_list:
clean_id += safe_char
break
return clean_id
def convert(self, filename):
from Products.ERP5OOo.OOoUtils import OOoParser
OOoParser = OOoParser()
import_file = read(self, filename)
# Extract tables from the speadsheet file
OOoParser.openFile(import_file)
filename = OOoParser.getFilename()
spreadsheets = OOoParser.getSpreadsheetsMapping()
table_dict = {}
for table_name, table in spreadsheets.items():
if not table:
continue
# Get the header of the table
columns_header = table[0]
# Get the mapping to help us to know the property according a cell index
property_map = {}
column_index = 0
for column in columns_header:
column_id = getIdFromString(column)
# The column has no header information
# The column has a normal header
property_map[column_index] = column_id
column_index += 1
# Construct categories data (with absolut path) from table lines
object_list = []
for line in table[1:]:
object_property_dict = {}
# Exclude empty lines
if line.count('') + line.count(None) == len(line):
continue
# Analyse every cells of the line
cell_index = 0
for cell in line:
# Ignore empty cells, do the test on the generated id
# because getIdFromString() is more restrictive
cell_id = getIdFromString(cell)
if cell_id not in ('', None):
# Get the property corresponding to the cell data
property_id = property_map[cell_index]
# Convert the value to something like '\xc3\xa9' not '\xc3\xa9'
object_property_dict[property_id] = cell.encode('UTF-8')
cell_index += 1
if len(object_property_dict) > 0:
object_list.append(object_property_dict)
table_dict[table_name.encode('UTF-8')] = object_list
if len(table_dict.keys()) == 1:
return object_list
else:
return table_dict
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class BusinessConfiguration:
"""
Properties of a Business Configuration.
"""
_properties = (
{ 'id' : 'configuration_after_script_id',
'description' : 'Defines the Id of the script to be ran after'
'the configuration.',
'type' : 'string',
'default' : 'BusinessConfiguration_afterConfiguration',
'mode' : 'w' },
)
_categories = ("current_state", "resource", "specialise")
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class CategoriesSpreadsheetConfiguratorItem:
""" Properties of a CategoriesSpreadsheetConfiguratorItem."""
_properties = (
{ 'id' : 'categories_spreadsheet',
'storage_id' : 'default_categories_spreadsheet',
'description' : 'A spreadsheet with categories definition',
'type' : 'content',
# XXX maybe it can just be a File, so that we don't have to depend on DMS
'portal_type' : ('Spreadsheet',),
'acquired_property_id' : ('file', 'content_type', 'data'),
'acquisition_base_category' : (),
'acquisition_portal_type' : (),
'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1,
'acquisition_sync_value' : 0,
'acquisition_accessor_id' : 'getDefaultCategoriesSpreadsheetValue',
'acquisition_depends' : None,
'mode' : 'w' },
)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class ConfigurationItem:
""" Properties of a Configuration Item."""
_properties = ({'id' : 'configuration_class_name',
'description' : 'Configuration class name',
'type' : 'string',
'mode' : 'w',
'default' : '' },
)
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class PortalTypeRolesSpreadsheetConfiguratorItem:
""" Properties of a PortalTypeRolesSpreadsheetConfiguratorItem."""
_properties = (
{ 'id' : 'portal_type_roles_spreadsheet',
'storage_id' : 'default_portal_type_roles_spreadsheet',
'description' : 'The spreadsheet for portal type roles configuration',
'type' : 'content',
'portal_type' : ('Spreadsheet',),
'acquired_property_id' : ('file', 'content_type', 'data'),
'acquisition_base_category' : (),
'acquisition_portal_type' : (),
'acquisition_copy_value' : 0,
'acquisition_mask_value' : 1,
'acquisition_sync_value' : 0,
'acquisition_accessor_id' : 'getDefaultPortalTypeRolesSpreadsheetValue',
'acquisition_depends' : None,
'mode' : 'w' },
)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class ServiceConfiguratorItem:
""" Properties of a ServiceConfiguratorItem."""
_properties = ({'id' : 'service',
'description' : 'Services',
'type' : 'lines',
'mode' : 'w',
'default' : []},
)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class SitePropertyConfiguratorItem:
""" Site Properties Configurator Item."""
_properties = ({'id' : 'site_property_list',
'description' : 'Site Property List',
'type' : 'lines',
'mode' : 'w',
'default' : []},)
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class StandardBT5ConfiguratorItem:
""" Properties of a ReturnStandardBT5ConfiguratorItem."""
_properties = ({'id' : 'bt5_id',
'description' : 'Business Template ID',
'type' : 'string',
'mode' : 'w',
'default' : 'erp5_base' },
)
This diff is collapsed.
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com>
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
"""
ERP5Configurator is a product containing everything needed to the
configurator.
"""
# Update ERP5 Globals
from Products.ERP5Type.Utils import initializeProduct, updateGlobals
import sys, Permissions
this_module = sys.modules[ __name__ ]
document_classes = updateGlobals(this_module, globals(),
permissions_module=Permissions)
from Tool import ConfiguratorTool
# Define object classes and tools
object_classes = ()
portal_tools = (ConfiguratorTool.ConfiguratorTool,
)
content_classes = ()
content_constructors = ()
# Finish installation
def initialize(context):
import Document
initializeProduct(context, this_module, globals(),
document_module=Document,
document_classes=document_classes,
object_classes=object_classes,
portal_tools=portal_tools,
content_constructors=content_constructors,
content_classes=content_classes)
##############################################################################
#
# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
# Rafael Monnerat <rafael@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from zope.interface import Interface
class IConfiguratorItem(Interface):
"""
Configurator Item interface specification.
Documents which implement the IConfiguratorItem interface
can be used to build an ERP5 Configuration.
"""
def build(business_configuration):
"""
Build new ERP5 Documents based on stored parameters during
the configuraton process.
business_configuration - Business Configuration Document that is
been used to configure.
"""
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com>
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class ConfiguratorItemMixin:
""" This is the base class for all configurator item. """
def install(self, object, business_configuration, prefix = ''):
""" Add object to customer customization template. """
bt5_obj = business_configuration.getSpecialiseValue()
if object.getPortalType() in ['Category', 'Base Category']:
prefix = "portal_categories/"
template_path_list = ['%s%s' % (prefix, object.getRelativeUrl()),
'%s%s/**' % (prefix, object.getRelativeUrl())]
current_template_path_list = list(bt5_obj.getTemplatePathList())
current_template_path_list.extend(template_path_list)
bt5_obj.edit(template_path_list=current_template_path_list)
def addToCustomerBT5ByRelativeUrl(self, business_configuration, relative_url_list):
""" Add object to customer customization template object by its relative url. """
bt5_obj = business_configuration.getSpecialiseValue()
current_template_path_list = list(bt5_obj.getTemplatePathList())
current_template_path_list.extend(relative_url_list)
bt5_obj.edit(template_path_list=current_template_path_list)
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