Skip to Content
Menu
This question has been flagged
1 Reply
3532 Views

Hello,

I want to create a dynamic fields.selection "A" from another value "X"

For example when the X=4;     my fields.selection will be as follows : 


fields.Selection(
[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), string='A', required=True)
Avatar
Discard
Best Answer

Selection field value will be loaded right after the Form is loaded, hence the selection values cannot be reset thereafter.

However I can suggest an alternate solution, you try it out if it meets your requirement.

Use Many2one relation "X", set the domain criteria based on your source field "Y", you can also define onchange on the field "Y", such that the domain is reset in accordance with "Y" field.

Tips: for "X" field, set widget-options to no-create, no-open etc, so that it may look like Selection, however don't set widget to Selection on "X", like I said above, selection options cannot be reset, after the form is loaded.

Avatar
Discard
Author

Thank you Deep, i will check that

Author

Can you give me an example how i will use many2one in my case ? thank you