Commit 1a4f2a69 authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Add select_variable property for Standard Property object in ERP5

This change solves the error which one gets while trying to access properties
Form for an ERP5 object having one or more of its property of type 'selection'
or 'multiple selection'.
For example: If you try to access property form for any portal_type objects,
you'll get an error : 'select_variable' is not defined. This is because of the
absence of the property select variable for the property of type multiple selection
which in case of portal_type object is property sheet list.

This is helpful for ERP5 views/forms which displays selection or multiple selection
type object.
parent 380fb229
...@@ -133,6 +133,10 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject): ...@@ -133,6 +133,10 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
'translation_domain', 'translation_domain',
'string') 'string')
getSelectVariable = Base.Getter('getSelectVariable',
'select_variable',
'string')
@classmethod @classmethod
def _asPropertyMap(cls, property_dict): def _asPropertyMap(cls, property_dict):
""" """
...@@ -158,6 +162,13 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject): ...@@ -158,6 +162,13 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
property_dict['base_id'] = property_dict['id'] property_dict['base_id'] = property_dict['id']
property_dict['id'] = property_dict['id'] + '_list' property_dict['id'] = property_dict['id'] + '_list'
# Maintain consistency while displaying proeprties form
# Addition of select_variable property helps for selection or multple selection
# property type as while rendering properties dtml file, it asks for
# select_variable property
if property_dict['type'] in ['selection', 'multiple selection']:
property_dict['select_variable'] = property_dict.pop('select_variable')
return property_dict return property_dict
@staticmethod @staticmethod
...@@ -609,7 +620,8 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject): ...@@ -609,7 +620,8 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
'read_permission': self.getReadPermission(), 'read_permission': self.getReadPermission(),
'write_permission': self.getWritePermission(), 'write_permission': self.getWritePermission(),
'translatable': self.getTranslatable(), 'translatable': self.getTranslatable(),
'translation_domain': self.getTranslationDomain()} 'translation_domain': self.getTranslationDomain(),
'select_variable': self.getSelectVariable()}
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'applyOnAccessorHolder') 'applyOnAccessorHolder')
......
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