本文介绍了依赖于odoo下拉菜单/打开erp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了两个下拉菜单.第二个下拉菜单的数据取决于第一个下拉菜单的选择值.

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.

这是我的三个列表:

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.

推荐答案

@ user32876

@user32876

第二个"field.selection"的语法不正确,它需要一个元组数组,而您正在尝试传递字典,这是错误的.第一个是正确的.您可以使用"on_change"方法根据第一个下拉菜单选择项来更改第二个下拉菜单的值.

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.

这篇关于依赖于odoo下拉菜单/打开erp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 01:54