Commit ef05ddc4 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Gather grouped portal types from portal_types rather than

hardcoding. For now, for the sake of backward-compatibility,
portal methods still fall back to site properties when
a given group has no portal type.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4395 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8efdfbdf
No related merge requests found
...@@ -26,6 +26,7 @@ from Products.ERP5Type.Document.Folder import FolderMixIn ...@@ -26,6 +26,7 @@ from Products.ERP5Type.Document.Folder import FolderMixIn
from Products.ERP5Type.Document import addFolder from Products.ERP5Type.Document import addFolder
from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire
from Products.ERP5Type import allowClassTool from Products.ERP5Type import allowClassTool
from Products.ERP5Type.Cache import CachingMethod
import ERP5Defaults import ERP5Defaults
from os import path from os import path
...@@ -270,40 +271,53 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -270,40 +271,53 @@ class ERP5Site ( CMFSite, FolderMixIn ):
return section_category return section_category
def _getPortalGroupedTypeList(self, group):
"""Return a list of portal types classified to a specific group.
"""
def getTypeList(group):
type_list = []
for pt in self.portal_types.objectValues():
if group in getattr(pt, 'group_list', ()):
type_list.append(pt.getId())
return tuple(type_list)
getTypeList = CachingMethod(getTypeList, id=('_getPortalGroupedTypeList', group), cache_duration=3600)
return getTypeList(group)
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalResourceTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalResourceTypeList')
def getPortalResourceTypeList(self): def getPortalResourceTypeList(self):
""" """
Return resource types. Return resource types.
""" """
return self._getPortalConfiguration('portal_resource_type_list') return self._getPortalGroupedTypeList('resource') or self._getPortalConfiguration('portal_resource_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalVariationTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalVariationTypeList')
def getPortalVariationTypeList(self): def getPortalVariationTypeList(self):
""" """
Return variation types. Return variation types.
""" """
return self._getPortalConfiguration('portal_variation_type_list') return self._getPortalGroupedTypeList('variation') or self._getPortalConfiguration('portal_variation_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalNodeTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalNodeTypeList')
def getPortalNodeTypeList(self): def getPortalNodeTypeList(self):
""" """
Return node types. Return node types.
""" """
return self._getPortalConfiguration('portal_node_type_list') return self._getPortalGroupedTypeList('node') or self._getPortalConfiguration('portal_node_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalInvoiceTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalInvoiceTypeList')
def getPortalInvoiceTypeList(self): def getPortalInvoiceTypeList(self):
""" """
Return invoice types. Return invoice types.
""" """
return self._getPortalConfiguration('portal_invoice_type_list') return self._getPortalGroupedTypeList('invoice') or self._getPortalConfiguration('portal_invoice_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalOrderTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalOrderTypeList')
def getPortalOrderTypeList(self): def getPortalOrderTypeList(self):
""" """
Return order types. Return order types.
""" """
return self._getPortalConfiguration('portal_order_type_list') return self._getPortalGroupedTypeList('order') or self._getPortalConfiguration('portal_order_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalDefaultCollection') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalDefaultCollection')
def getPortalDefaultCollection(self): def getPortalDefaultCollection(self):
...@@ -317,7 +331,7 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -317,7 +331,7 @@ class ERP5Site ( CMFSite, FolderMixIn ):
""" """
Return delivery types. Return delivery types.
""" """
return self._getPortalConfiguration('portal_delivery_type_list') return self._getPortalGroupedTypeList('delivery') or self._getPortalConfiguration('portal_delivery_type_list')
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getPortalTransformationTypeList') 'getPortalTransformationTypeList')
...@@ -325,7 +339,7 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -325,7 +339,7 @@ class ERP5Site ( CMFSite, FolderMixIn ):
""" """
Return transformation types. Return transformation types.
""" """
return self._getPortalConfiguration('portal_transformation_type_list') return self._getPortalGroupedTypeList('transformation') or self._getPortalConfiguration('portal_transformation_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalVariationBaseCategoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalVariationBaseCategoryList')
def getPortalVariationBaseCategoryList(self): def getPortalVariationBaseCategoryList(self):
...@@ -347,28 +361,28 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -347,28 +361,28 @@ class ERP5Site ( CMFSite, FolderMixIn ):
""" """
Return invoice movement types. Return invoice movement types.
""" """
return self._getPortalConfiguration('portal_invoice_movement_type_list') return self._getPortalGroupedTypeList('invoice_movement') or self._getPortalConfiguration('portal_invoice_movement_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalOrderMovementTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalOrderMovementTypeList')
def getPortalOrderMovementTypeList(self): def getPortalOrderMovementTypeList(self):
""" """
Return order movement types. Return order movement types.
""" """
return self._getPortalConfiguration('portal_order_movement_type_list') return self._getPortalGroupedTypeList('order_movement') or self._getPortalConfiguration('portal_order_movement_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalDeliveryMovementTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalDeliveryMovementTypeList')
def getPortalDeliveryMovementTypeList(self): def getPortalDeliveryMovementTypeList(self):
""" """
Return delivery movement types. Return delivery movement types.
""" """
return self._getPortalConfiguration('portal_delivery_movement_type_list') return self._getPortalGroupedTypeList('delivery_movement') or self._getPortalConfiguration('portal_delivery_movement_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalDeliveryMovementTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalDeliveryMovementTypeList')
def getPortalSupplyTypeList(self): def getPortalSupplyTypeList(self):
""" """
Return supply types. Return supply types.
""" """
return self._getPortalConfiguration('portal_supply_type_list') return self._getPortalGroupedTypeList('supply') or self._getPortalConfiguration('portal_supply_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalAcquisitionMovementTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalAcquisitionMovementTypeList')
def getPortalAcquisitionMovementTypeList(self): def getPortalAcquisitionMovementTypeList(self):
...@@ -389,56 +403,56 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -389,56 +403,56 @@ class ERP5Site ( CMFSite, FolderMixIn ):
""" """
Return simulated movement types. Return simulated movement types.
""" """
return tuple(filter(lambda x: x != 'Container Line' and x != 'Container Cell', self.getPortalMovementTypeList())) return tuple([x for x in self.getPortalMovementTypeList() if x not in self.getPortalContainerTypeList()])
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalContainerTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalContainerTypeList')
def getPortalContainerTypeList(self): def getPortalContainerTypeList(self):
""" """
Return container types. Return container types.
""" """
return self._getPortalConfiguration('portal_container_type_list') return self._getPortalGroupedTypeList('container') or self._getPortalConfiguration('portal_container_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalContainerLineTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalContainerLineTypeList')
def getPortalContainerLineTypeList(self): def getPortalContainerLineTypeList(self):
""" """
Return container line types. Return container line types.
""" """
return self._getPortalConfiguration('portal_container_line_type_list') return self._getPortalGroupedTypeList('container_line') or self._getPortalConfiguration('portal_container_line_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalItemTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalItemTypeList')
def getPortalItemTypeList(self): def getPortalItemTypeList(self):
""" """
Return item types. Return item types.
""" """
return self._getPortalConfiguration('portal_item_type_list') return self._getPortalGroupedTypeList('item') or self._getPortalConfiguration('portal_item_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalDiscountTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalDiscountTypeList')
def getPortalDiscountTypeList(self): def getPortalDiscountTypeList(self):
""" """
Return discount types. Return discount types.
""" """
return self._getPortalConfiguration('portal_discount_type_list') return self._getPortalGroupedTypeList('discount') or self._getPortalConfiguration('portal_discount_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalAlarmTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalAlarmTypeList')
def getPortalAlarmTypeList(self): def getPortalAlarmTypeList(self):
""" """
Return alarm types. Return alarm types.
""" """
return self._getPortalConfiguration('portal_alarm_type_list') return self._getPortalGroupedTypeList('alarm') or self._getPortalConfiguration('portal_alarm_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalPaymentConditionTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalPaymentConditionTypeList')
def getPortalPaymentConditionTypeList(self): def getPortalPaymentConditionTypeList(self):
""" """
Return payment condition types. Return payment condition types.
""" """
return self._getPortalConfiguration('portal_payment_condition_type_list') return self._getPortalGroupedTypeList('payment_condition') or self._getPortalConfiguration('portal_payment_condition_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalBalanceTransactionLineTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalBalanceTransactionLineTypeList')
def getPortalBalanceTransactionLineTypeList(self): def getPortalBalanceTransactionLineTypeList(self):
""" """
Return balance transaction line types. Return balance transaction line types.
""" """
return self._getPortalConfiguration('portal_balance_transaction_line_type_list') return self._getPortalGroupedTypeList('balance_transaction_line') or self._getPortalConfiguration('portal_balance_transaction_line_type_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalCurrentInventoryStateList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalCurrentInventoryStateList')
def getPortalCurrentInventoryStateList(self): def getPortalCurrentInventoryStateList(self):
...@@ -513,7 +527,7 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -513,7 +527,7 @@ class ERP5Site ( CMFSite, FolderMixIn ):
""" """
Return accounting movement type list. Return accounting movement type list.
""" """
return self._getPortalConfiguration('portal_accounting_movement_type_list') return self._getPortalGroupedTypeList('accounting_movement') or self._getPortalConfiguration('portal_accounting_movement_type_list')
def getPortalAssignmentBaseCategoryList(self): def getPortalAssignmentBaseCategoryList(self):
""" """
......
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