--- a/web/test/unittest_views_basecontrollers.py Tue Jan 21 12:34:14 2014 +0100
+++ b/web/test/unittest_views_basecontrollers.py Wed Sep 11 18:04:05 2013 +0200
@@ -221,6 +221,21 @@
# created before.
self.assertGreater(salesterm.eid, salesterm.described_by_test[0].eid)
+ def test_edit_mandatory_inlined3_object(self):
+ # non regression test for #3120495. Without the fix, leads to
+ # "unhashable type: 'list'" error
+ req = self.request()
+ cwrelation = u(req.execute('CWEType X WHERE X name "CWSource"')[0][0])
+ req.form = {'eid': [cwrelation], '__maineid' : cwrelation,
+
+ '__type:'+cwrelation: 'CWEType',
+ '_cw_entity_fields:'+cwrelation: 'to_entity-object',
+ 'to_entity-object:'+cwrelation: [9999, 9998],
+ }
+ with self.session.deny_all_hooks_but():
+ path, params = self.expect_redirect_handle_request(req, 'edit')
+ self.assertTrue(path.startswith('cwetype/CWSource'), path)
+
def test_edit_multiple_linked(self):
req = self.request()
peid = u(self.create_user(req, 'adim').eid)
--- a/web/views/editcontroller.py Tue Jan 21 12:34:14 2014 +0100
+++ b/web/views/editcontroller.py Wed Sep 11 18:04:05 2013 +0200
@@ -158,7 +158,7 @@
# if cardinality is 1 and if the target entity is being
# simultaneously edited, the current entity must be
# created before the target one
- if rdef.cardinality[0] == '1':
+ if rdef.cardinality[0 if role == 'subject' else 1] == '1':
target_eid = values[param]
if target_eid in values_by_eid:
# add dependency from the target entity to the