Ir al contenido
Menú
Se marcó esta pregunta
5 Respuestas
16077 Vistas

Hello guys,

Let me give you some example

E.g : 

state = fields.Selection([
                                          ('1', '1 Years'), 
                                          ('2', '2 Years'),
                                          ('3', '3 Years'),
                                          ('4', '4 Years'),
                                          ('5', '5 Years'),
                                          ('6', '6 Years')], 
                                          string='Period'')

there is 2 boolean e.g : bool_assosiate and bool_professional

if bool_associate :

                  hide 2 - 4 - 6 Years

if bool_professional :              

                  hide 1 - 3 - 5 years

it will hidden based on that condition in xml view

Thank you,
Best Regards,
Chaanto


Avatar
Descartar

Do you want to hide it in statusbar?

Mejor respuesta

To add more context to this question, can you please provide the information of those 2 boolean fields that you are using? These fields values are default on record init, or accessible through self._context?. 

According to these additional context, you can create model method, or method to return a list of (value, string), through selection=method (fields.Selection attribute), with the initial list (1,2,3,4,5,6) as default variable on top of your code.

Avatar
Descartar
Mejor respuesta

Hi Chaanto,


There are two ways you can achieve:

1) Creating two selection fields, show relevant selection field based on your requirement and hide using attrs

2) Creating Many2one fields and hiding the unwanted records based on domain.


Hope this helps. 



Avatar
Descartar
Mejor respuesta

In the statusbar is easy to hide you need to set the invisible attribute attrs="{'invisible':['|',('condition','goes','here')]}"... but if i understand correctly you need to show different selection range based on a boolean condition so the best solution is to split the selection in 2 selections and use an invisible with the boolean condition that show or hide your elements

Avatar
Descartar
Autor

the problem is how i can hide that option, if i using invsible syntax that should be hide all option on the selection field, but what i need is hide a few option in the selection field, just like my example when i choose associate boolean 2 - 4 - 6 years option should be gone and will show 1 - 3 - 5 years

Thank You,

Best Regards,

Chaanto

Publicaciones relacionadas Respuestas Vistas Actividad
4
may 20
3289
0
mar 15
8950
1
nov 23
3055
1
dic 20
4364
4
dic 23
22129