# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1241596070 -7200 # Node ID a2b5dfdb4b6276070a626f49a58e83e076161189 # Parent 312310ed8a2f047e8859232433d9af92b60b34f6 should prefill cached values for relation in the primary or secondary category diff -r 312310ed8a2f -r a2b5dfdb4b62 web/views/editforms.py --- a/web/views/editforms.py Wed May 06 09:46:36 2009 +0200 +++ b/web/views/editforms.py Wed May 06 09:47:50 2009 +0200 @@ -230,7 +230,7 @@ # request's cache. entity.complete() self.newentity = copy(entity) - self.copying = self.newentity.eid + self.copying = entity self.initialize_varmaker() self.newentity.eid = self.varmaker.next() self.w(u'\n' @@ -242,7 +242,14 @@ """customize your form before rendering here""" super(CopyFormView, self).init_form(form, entity) if entity.eid == self.newentity.eid: - form.form_add_hidden(eid_param('__cloned_eid', entity.eid), self.copying) + form.form_add_hidden(eid_param('__cloned_eid', entity.eid), + self.copying.eid) + for rschema, _, role in form.relations_by_category(form.attrcategories, + 'add'): + if not rschema.is_final(): + # ensure relation cache is filed + rset = self.copying.related(rschema, role) + self.newentity.set_related_cache(rschema, role, rset) def submited_message(self): """return the message that will be displayed on successful edition"""