Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
7614 Visualizzazioni

I have a many2one field state_id from res.country.state. Based on the state I want the view to change with

attrs="{'invisible':[('state_id', '=', '39')]}

and

colors="red:state_id=='39'"

Both cause errors. So I try state_id equals 'Pennsylvania' and more errors. Then since the data is passed via JSON as an object I try state_id.id and more errors. So then I try state_id[0] with same result. There must be a way to use conditionals in views with many2one fields like this although I could not find examples in the source code of various addons. Does anybody know the way to handle this?

Avatar
Abbandona
Risposta migliore

Hi as i don't want you to use state_id or many2one field like that

you my suggestion is that you should use state_id.name and give the 'name' that which country you want.

or if you still want state_id then just do like below

  attrs="{'invisible':[('state_id.id', '=', 39)]}

  and

  colors="red:state_id.id==39"

but you should use name because in this case you can change the name of country in user interface while you can not change ID so it should be like

  attrs="{'invisible':[('state_id.name', '=','Newyork')]}

  and

  colors="red:state_id.name=='Newyork'"

Thanks
Sandeep

Avatar
Abbandona
Autore

I got this: Error: QWeb2 - template['ListView.rows']: Runtime Error: Error: QWeb2 - template['ListView.row']: Runtime Error: Error: AttributeError: object has no attribute 'name'

i'm also same error

Post correlati Risposte Visualizzazioni Attività
1
giu 17
5280
3
lug 24
3095
1
mar 22
9811
3
ott 18
5086
0
mar 15
3742