web/views/autoform.py
changeset 6630 f516ee1ef36c
parent 6577 0d9ea7f93065
child 6725 6e6d1d19f341
--- a/web/views/autoform.py	Mon Oct 25 15:52:10 2010 +0200
+++ b/web/views/autoform.py	Mon Oct 25 16:28:05 2010 +0200
@@ -837,10 +837,13 @@
             # to add new related entities
             if self.should_display_add_new_relation_link(rschema, formviews, card):
                 rdef = entity.e_schema.rdef(rschema, role, ttype)
-                if role == 'subject':
-                    rdefkwargs = {'fromeid': entity.eid}
+                if entity.has_eid():
+                    if role == 'subject':
+                        rdefkwargs = {'fromeid': entity.eid}
+                    else:
+                        rdefkwargs = {'toeid': entity.eid}
                 else:
-                    rdefkwargs = {'toeid': entity.eid}
+                    rdefkwargs = {}
                 if (tschema.has_perm(self._cw, 'add')
                     and rdef.has_perm(self._cw, 'add', **rdefkwargs)):
                     addnewlink = self._cw.vreg['views'].select(