Return BrowseRecordNull for relation field in wizard session

review250001
This commit is contained in:
Cédric Krier committed 2012-02-24 11:06:40 +01:00
1 parent 8a01bb2178
commit d73fae86f5
2 files changed
+9 -5

No files matched your search

+1
View File
@@ -35,6 +35,7 @@ class WizardTestCase(unittest.TestCase):
session = Session(self.wizard, session_id)
self.assertEqual(session.start.name, False)
session.start.name = 'Test'
self.assertEqual(session.start.user.id, False)
session.start.user = USER
session.start.groups = [
{'name': 'Group A'},
+8 -5
View File
@@ -16,6 +16,7 @@ from trytond.url import URLMixin
from trytond.protocols.jsonrpc import object_hook, JSONEncoder
from trytond.model.fields import states_validate
from trytond.pyson import PYSONEncoder
from trytond.model.browse import BrowseRecordNull
class Button(object):
@@ -159,12 +160,12 @@ class _SessionRecord(object):
return self.__cache[name]
field = self._model._columns[name]
data = self._data.get(name, False)
target_obj = None
if hasattr(field, 'model_name'):
target_obj = Pool().get(field.model_name)
elif hasattr(field, 'get_target'):
target_obj = field.get_target()
if data:
target_obj = None
if hasattr(field, 'model_name'):
target_obj = Pool().get(field.model_name)
elif hasattr(field, 'get_target'):
target_obj = field.get_target()
if target_obj:
def instance(data):
if isinstance(data, dict):
@@ -174,6 +175,8 @@ class _SessionRecord(object):
data = [instance(x) for x in data]
else:
data = instance(data)
elif target_obj:
return BrowseRecordNull()
self.__cache[name] = data
return data