Commit 4068924a authored by Jérome Perrin's avatar Jérome Perrin

ERP5Form: fix Form.proxifyField when field only has TALES

The internal data structures are made of two dicts: .values for values and
.tales for TALES. Formulator expect that these two dicts have keys for all
properties, because of the implementation of Field.has_value which checks
for the presence of the key in .values

When making a field with only TALES, this method was setting the value only
in .tales but the same key needs to be present also in .values, otherwise
get_value would return False for this key.
parent 974f4347
......@@ -134,6 +134,7 @@ class TestProxify(ERP5TypeTestCase):
self.assertEqual(field.is_delegated('items'), False)
self.assertEqual(field.get_tales('items')._text,
'here/portal_categories/region/getCategoryChildTranslatedLogicalPathItemList')
self.assertTrue(field.has_value('items'))
self.assertEqual(field.is_delegated('enabled'), True)
self.assertEqual(field.get_value('enabled'), 1)
self.assertEqual(field.is_delegated('description'), True)
......
......@@ -1184,13 +1184,14 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
new_tales[i]):
del new_tales[i]
delegated_list = []
for i in (new_values.keys()+new_tales.keys()):
if not i in delegated_list:
delegated_list.append(i)
# make sure every TALES is also in values, this is required for has_value
for key in new_tales:
if key not in new_values:
new_values[key] = proxy_field.get_recursive_orig_value(key, include=0)
proxy_field.values.update(new_values)
proxy_field.tales.update(new_tales)
proxy_field.delegated_list = sorted(delegated_list)
proxy_field.delegated_list = list(sorted(new_values.keys()))
# move back to the original group and position.
set_group_and_position(group, position, field_id)
......
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