Commit 0c2c3a88 authored by Sebastien Robin's avatar Sebastien Robin

ERP5Type.Base: do not look for related objects on temp objects

Doing get[CategoryName]RelatedValueList or similar accessors on temp
objects makes the category tool raising errors since last code
refactoring. Since the concept of temp object is specific to ERP5, just
make sure in ERP5 low level code that we do not try to call category
tool on temp object for getting related object.
parent 4e444654
......@@ -1981,7 +1981,11 @@ class Base( CopyContainer,
getDefaultRelatedValue = _getDefaultRelatedValue
def _getRelatedValueList(self, *args, **kw):
# a temp object does not really exist, it has no path, thus there is no
# chance to have any single related object.
# backward compatibility to keep strict keyword working
if self.isTempObject():
return []
if 'strict' in kw:
kw['strict_membership'] = kw.pop('strict')
return self._getCategoryTool().getRelatedValueList(self, *args, **kw)
......
......@@ -450,6 +450,15 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
method = getattr(person_property_sheet, 'getRegionRelatedList', None)
self.assertNotEquals(None, method)
def test_04b_CategoryAccessorsOnTempObjects(self):
"""
basic category methods test on temp objects
"""
person_object = self.getPersonModule().newContent(
portal_type = "Person",
first_name="John", last_name="Smith",
temp_object = 1)
self.assertEqual([], person_object.getRegionRelatedValueList())
def test_05_setProperty(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