[inline form] ensure entity has an actual eid before using it to check perms
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 25 Oct 2010 16:28:05 +0200
changeset 6630 f516ee1ef36c
parent 6629 edaa96d031b2
child 6631 26c303c3f1aa
[inline form] ensure entity has an actual eid before using it to check perms
web/views/autoform.py
--- 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(