问题
I have made two drop-downs. Second dropdown's data is dependent on first drop-down's chosen value.
I have tried multiple methods, but didn't find any relevant solution.
Those are my three lists:
SELECTION_LIST = (('sela','Selected a'),
('selb','Selected b'))
SELECTION_LIST_2 = (('selc','Selected c'),
('seld','Selected d'))
SELECTION_LIST_3 = (('sele','Selected e'),
('self','Selected f'))
And I defined my fields this way:
'type_selection': fields.selection(
[
('selection1', 'Selection 1'),
('selection2', 'Selection 2'),
('selection3', 'Selection 3'),
], 'Category 1', required=False),
'type_selection_2': fields.selection(
type_selection={
'selection1': [{SELECTION_LIST}],
'selection2': [{SELECTION_LIST_2}],
'selection3': [{SELECTION_LIST_3}],
}, "Category 2", required=False)
Unfortunately I get an error.
回答1:
Try by using domain with on_change() methods.
回答2:
@user32876
Incorrect syntax for second 'field.selection', it takes an array of tuple and you are trying to pass a dictionary, which is wrong. First one is correct. And you can use 'on_change' method to change the value of second dropdown based on the first dropdown selection.
Post your code for better understanding and explain what exactly you want to do.
来源:https://stackoverflow.com/questions/26591360/dependent-drop-down-in-odoo-open-erp