Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
5 Vastaukset
15685 Näkymät

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
Hylkää

Do you want to hide it in statusbar?

Paras vastaus

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
Hylkää
Paras vastaus

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
Hylkää
Paras vastaus

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
Hylkää
Tekijä

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

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
4
toukok. 20
2974
0
maalisk. 15
8644
1
marrask. 23
2631
1
jouluk. 20
3776
4
jouluk. 23
21519