Skip to Content
Menu
This question has been flagged
5 Replies
15680 Views

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
Discard

Do you want to hide it in statusbar?

Best Answer

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Author

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

Related Posts Replies Views Activity
4
May 20
2974
0
Mar 15
8641
1
Nov 23
2630
1
Dec 20
3774
4
Dec 23
21514