Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Dynamically change choices in selection fields

By
Matt
on 5/1/13, 2:07 PM 3,654 views

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

0
arif
On 5/2/13, 2:59 AM

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.

1

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 5/2/13, 2:25 AM

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

return {'value': {'your_selection_field': 'your_selection_field_value'}}
1
Matt
On 5/2/13, 12:32 PM

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

ECP D
on 5/2/13, 2:04 PM

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 !

Matt
on 5/2/13, 3:02 PM

Thx any way

ECP D
on 5/3/13, 6:02 AM
0
Lars
On 5/2/13, 7:23 AM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 5/1/13, 2:07 PM
Seen: 3654 times
Last updated: 3/16/15, 8:10 AM