On 14/01/10 15:09 -0500, Juan Fernando Jaramillo Botero wrote:
> On Thu, Jan 14, 2010 at 07:57:28PM +0100, Cédric Krier wrote:
> > On 14/01/10 11:50 -0500, Juan Fernando Jaramillo Botero wrote:
> > > Hello, someone know how to add a item to one context of a record of a
> > > model that have a field Many2One in such a way that it could be read from
> > > the records that belong to the first record?
> > >
> > > I have something like this:
> > >
> > > class OrdenDeTrabajo(ModelWorkflow, ModelSQL, ModelView):
> > > 'Ordenes de Trabajo'
> > > _name = 'taller.ordendetrabajo'
> > > _description = __doc__
> > > _order_name="id"
> > > descriptions =
> > > fields.One2Many('taller.description','ordendetrabajo','Descripciones',
> > > states=STATES)
> > > ...
> > >
> > > class Description(ModelSQL, ModelView):
> > > 'descripciones de una orden'
> > > _name = 'taller.description'
> > > _description = __doc__
> > > #_rec_name="id"
> > > _order_name="id"
> > >
> > > ordendetrabajo = fields.Many2One('taller.ordendetrabajo','Orden de
> > > Trabajo',required=True, select=1, states=STATES)
> > >
> > > I was try to add the parameter: context = "{'tipo_pintura':'BC'}", first
> > > in the field descriptions, and them in the field ordendetrabajo, but
> > > doesn't work.
> > >
> > > Some idea?
> >
> > If I have well understand, it should work:
> >
> > ordendetrabajo = fields.Many2One('taller.ordendetrabajo','Orden de
> > Trabajo',required=True, select=1, states=STATES,
> > context={'tipo_pintura':'BC'})
> >
> Well, actually it was I try, but it doesn't add the item 'tipo_pintura' to
> the context.
>
> The point to be more concret, is how can I add new variables to the context?Where do you want to have this context set? Normally, with the code above you will have this context for the call of default_get. -- Cédric Krier B2CK SPRL Rue de Rotterdam, 4 4000 Liège Belgium Tel: +32 472 54 46 59 Email: [email protected] Jabber: [email protected] Website: http://www.b2ck.com/ twitter: http://twitter.com/cedrickrier identi.ca: http://identi.ca/cedrickrier
pgpOsxp8Rumsu.pgp
Description: PGP signature
