dependent drop-down in odoo / open erp

允我心安 提交于 2019-12-08 03:45:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!