On 2015-11-20 10:58, Sergi Almacellas Abellana wrote:
> El 19/11/15 a les 15:30, Antonio Roncero ha escrit:
> >
> >
> >El jueves, 19 de noviembre de 2015, 14:15:51 (UTC), Sergi Almacellas
> >Abellana escribió:
> >
> > El 19/11/15 a les 12:04, Antonio Roncero ha escrit:
> > > Hi,
> > >
> > > In a particular case, i need to make invisible the name field on the
> > > party model and use only code field. In this case i need to make
> > visible
> > > a page. I use the classmethod view_attributes
> > >
> > > |
> > >
> > > @classmethod
> > > defview_attributes(cls):
> > > return[('/form//field[@name="name"]','states',{
> > > 'invisible':Eval('is_robot'),
> > > }),
> > > ('//page[@id="party_robot_data"]','states',{
> > > 'invisible':~Eval('is_robot'),
> > > }),
> > > ]
> > >
> > > |
> > >
> > > The second part works fine, but the field "name" not change. I tried
> > > with /form/field[@name="name"]
> > > /form//field[@name="name"] //form/field[@name="name"]
> > > //field[@name="name"] /field[@name="name"]...
> > > I don't know if I am writing bad the xpath or there is another error
> > >
> >
> > Why are you only setting the states on the view and not on the field? I
> > will override the states on name field, on the __setup__ function, so
> > it's applied to all the views.
> >
> > Also make sure that the is_robot field is added to the name depends, so
> > the client will always fetch the is_robot field.
> >
> >Really because I still am in the learning phase, so I don't know all the
> >framework possibilities (I don't find to much doc and I'm reading a lot
> >of other people modules). :P
> >But that code must be work, no? The second part makes the changes, the
> >first part doesn't anything...
>
> Yes the code must work, but can not give more help, without knowing more
> about the view definition. I suspect it's the xpath that's not applying
> correctly.
No it can not work because the field definition override any XML view
states. By the way, states attribute is not allowed on field tag, see
trytond/ir/ui/form.rnc
--
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
--
You received this message because you are subscribed to the Google Groups
"tryton" group.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tryton/20151120142934.GE15014%40tetsuo.b2ck.com.