261 super(AddRelatedActions, self).fill_menu(box, menu) |
261 super(AddRelatedActions, self).fill_menu(box, menu) |
262 |
262 |
263 def actual_actions(self): |
263 def actual_actions(self): |
264 entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
264 entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
265 eschema = entity.e_schema |
265 eschema = entity.e_schema |
266 for rschema, teschema, x in self.add_related_schemas(entity): |
266 for rschema, teschema, role in self.add_related_schemas(entity): |
267 if x == 'subject': |
267 if rschema.role_rdef(eschema, teschema, role).role_cardinality(role) in '1?': |
268 label = 'add %s %s %s %s' % (eschema, rschema, teschema, x) |
268 if entity.related(rschema, role): |
|
269 continue |
|
270 if role == 'subject': |
|
271 label = 'add %s %s %s %s' % (eschema, rschema, teschema, role) |
269 url = self.linkto_url(entity, rschema, teschema, 'object') |
272 url = self.linkto_url(entity, rschema, teschema, 'object') |
270 else: |
273 else: |
271 label = 'add %s %s %s %s' % (teschema, rschema, eschema, x) |
274 label = 'add %s %s %s %s' % (teschema, rschema, eschema, role) |
272 url = self.linkto_url(entity, rschema, teschema, 'subject') |
275 url = self.linkto_url(entity, rschema, teschema, 'subject') |
273 yield self.build_action(self._cw._(label), url) |
276 yield self.build_action(self._cw._(label), url) |
274 |
277 |
275 def add_related_schemas(self, entity): |
278 def add_related_schemas(self, entity): |
276 """this is actually used ui method to generate 'addrelated' actions from |
279 """this is actually used ui method to generate 'addrelated' actions from |