698 onchange="javascript: addPendingInsert(this.options[this.selectedIndex], %s, %s, '%s');"> |
698 onchange="javascript: addPendingInsert(this.options[this.selectedIndex], %s, %s, '%s');"> |
699 %s |
699 %s |
700 </select> |
700 </select> |
701 </div> |
701 </div> |
702 """ % (hidden and 'hidden' or '', divid, selectid, |
702 """ % (hidden and 'hidden' or '', divid, selectid, |
703 xml_escape(json_dumps(entity.eid)), is_cell and 'true' or 'null', |
703 xml_escape(json_dumps(entity.eid)), is_cell and 'true' or 'null', |
704 relname, '\n'.join(options)) |
704 relname, '\n'.join(options)) |
705 |
705 |
706 def _get_select_options(self, entity, rschema, role): |
706 def _get_select_options(self, entity, rschema, role): |
707 """add options to search among all entities of each possible type""" |
707 """add options to search among all entities of each possible type""" |
708 options = [] |
708 options = [] |
709 pending_inserts = get_pending_inserts(self._cw, entity.eid) |
709 pending_inserts = get_pending_inserts(self._cw, entity.eid) |
814 if field.fieldset not in fsio: |
814 if field.fieldset not in fsio: |
815 fsio.append(field.fieldset) |
815 fsio.append(field.fieldset) |
816 if self.formtype == 'main': |
816 if self.formtype == 'main': |
817 # add the generic relation field if necessary |
817 # add the generic relation field if necessary |
818 if entity.has_eid() and ( |
818 if entity.has_eid() and ( |
819 self.display_fields is None or |
819 self.display_fields is None |
820 '_cw_generic_field' in self.display_fields): |
820 or '_cw_generic_field' in self.display_fields): |
821 try: |
821 try: |
822 field = self.field_by_name('_cw_generic_field') |
822 field = self.field_by_name('_cw_generic_field') |
823 except f.FieldNotFound: |
823 except f.FieldNotFound: |
824 # no editable relation |
824 # no editable relation |
825 pass |
825 pass |
955 by default true if there is no related entity or if the relation has |
955 by default true if there is no related entity or if the relation has |
956 multiple cardinality and it is permitted to add the inlined object and |
956 multiple cardinality and it is permitted to add the inlined object and |
957 relation. |
957 relation. |
958 """ |
958 """ |
959 return (self.should_display_add_new_relation_link( |
959 return (self.should_display_add_new_relation_link( |
960 rschema, existing, card) and |
960 rschema, existing, card) |
961 self.check_inlined_rdef_permissions( |
961 and self.check_inlined_rdef_permissions( |
962 rschema, role, tschema, ttype)) |
962 rschema, role, tschema, ttype)) |
963 |
963 |
964 def check_inlined_rdef_permissions(self, rschema, role, tschema, ttype): |
964 def check_inlined_rdef_permissions(self, rschema, role, tschema, ttype): |
965 """return true if permissions are granted on the inlined object and |
965 """return true if permissions are granted on the inlined object and |
966 relation""" |
966 relation""" |
967 if not tschema.has_perm(self._cw, 'add'): |
967 if not tschema.has_perm(self._cw, 'add'): |