diff --git a/product/ERP5Form/PreferenceTool.py b/product/ERP5Form/PreferenceTool.py index 2dafda1e477214f1faf7cddffd44759d37ad66ea..a25e26fd905b4002b6a9ca82823028d9cd2b2781 100644 --- a/product/ERP5Form/PreferenceTool.py +++ b/product/ERP5Form/PreferenceTool.py @@ -93,8 +93,10 @@ def createPreferenceToolAccessorList(portal) : # only properties marked as preference are used attribute = prop['id'] attr_list = [ 'get%s' % convertToUpperCase(attribute)] + if prop['type'] == 'boolean': + attr_list.append('is%s' % convertToUpperCase(attribute)) if prop['type'] in list_types : - attr_list += ['get%sList' % convertToUpperCase(attribute), ] + attr_list.append('get%sList' % convertToUpperCase(attribute)) for attribute_name in attr_list: method = PreferenceMethod(attribute_name, prop.get('default')) setattr(PreferenceTool, attribute_name, method) diff --git a/product/ERP5Form/tests/testPreferences.py b/product/ERP5Form/tests/testPreferences.py index 8935d779afda533c464843be94d3a13721d37d2a..d199ccd3bde82a5175b22786dfca54df99cfb95e 100644 --- a/product/ERP5Form/tests/testPreferences.py +++ b/product/ERP5Form/tests/testPreferences.py @@ -509,6 +509,26 @@ class TestPreferences(ERP5TypeTestCase): self.assertEqual(user_pref, preference_tool.getActivePreference()) self.assertEqual(system_pref, preference_tool.getActiveSystemPreference()) + def test_boolean_accessor(self): + self._addPropertySheet('Preference', 'DummyPreference', + '''class DummyPreference: + _properties= ( {'id': 'dummy', + 'preference': True, + 'type': 'boolean',},)''') + portal_preferences = self.portal.portal_preferences + self.assertFalse(portal_preferences.getDummy()) + self.assertFalse(portal_preferences.isDummy()) + + preference = portal_preferences.newContent(portal_type='Preference', + dummy=True) + preference.enable() + transaction.commit() + self.tic() + + self.assertTrue(portal_preferences.getDummy()) + self.assertTrue(portal_preferences.isDummy()) + + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestPreferences))