Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
15581 มุมมอง

I have a selection field with different choices in a form. How can I dynamically change the choices in an on_change function?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Just return the value of selection field from onchange based on your requirement.

return {'value': {'your_selection_field': 'your_selection_field_value'}}
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I think you need to change choice set in selection widget. If so my answer it is.

It is not possible to change choices of 'Selection' widget after once the values loaded. If you need to display different choices, you have to use multiple selection fields (with same label) with different set of choices and make one of them visible on change.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thanks for your answers. I solved my problem with 2 selection fields:

<field name="see_more" /> 
<field name="basic_selection"  attrs="{'invisible':[('see_more','==',False)]}"  />
<field name="extended_selection" attrs="{'invisible':[('see_more','==',True)]}"/>

I had a problem with the domain solution: the fields were correctly loaded when I opened the window but I couldn't change them dynamicaly when I checked the boolean field 'see_more'

However, with the chosen solution I had to adapt the python code that deals with the selection field...

อวตาร
ละทิ้ง

Hi Mat, not in this subject, but near.. i want to display all partner related messages, in the lower part of the partner form, where alredy have a partner DOCUMENT related mail wall, but the document relation is th problem, cause i want to see there the ALL partner related messages(incoming outgoing). For this view the res.partner.emails.info.inherit responsible, but just one line : <field name="message_ids" widget="mail_thread" options="{"thread_level": 0}"/> Do u have maybe any idea, how can this set to receive all messages in this view? Thx

ผู้เขียน

Sorry but I have never dealt with that part of openerp (mails, messages,...), I'm afraid I can't help you... Try to open a new subject, Good luck !

Thx any way

คำตอบที่ดีที่สุด

Hi, 

You can follow following link for this:

https://youtu.be/GPhgxxwprA4

Hope it helps,

Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Best way should be to work with a domain filter on the field, showing you only a selection of values, depending on a condition. You may also use this as many2one field with a selection widget. Dont know if that would serve your purpose.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
ธ.ค. 23
22236
Working with fields.selection values แก้ไขแล้ว
1
มิ.ย. 22
27107
9
พ.ค. 22
53349
0
ก.ค. 20
2920
0
มี.ค. 20
3752