تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
5 الردود
15697 أدوات العرض

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


الصورة الرمزية
إهمال

Do you want to hide it in statusbar?

أفضل إجابة

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.

الصورة الرمزية
إهمال
أفضل إجابة

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. 



الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
الكاتب

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
4
مايو 20
2975
0
مارس 15
8646
1
نوفمبر 23
2642
1
ديسمبر 20
3778
4
ديسمبر 23
21533