简体   繁体   English

Odoo / OpenERP:在fields.selection中隐藏一些值

[英]Odoo/OpenERP: Make invisible some values inside a fields.selection

I have a field selection ( fields.selection ) with different values. 我有一个具有不同值的字段selectionfields.selection )。

Some values are only for some automatic action. 某些值仅适用于某些自动操作。 Thus, I would like to make then "invisible" when users can select a value from this selection field. 因此,当用户可以从此选择字段中选择值时,我想使其“不可见”。 Is it possible? 可能吗? I try attrs="{'invisible'} without success. 我尝试了attrs="{'invisible'}但没有成功。

My field: 我的领域:

'titre': fields.selection(
     (
         ('e', 'Email'),
         ('p', 'phone'),
         ('m','Post/Mail'),
         ('a', 'Automatic Action')
     ),
     'Action',
      required=True
 )

Here is my xml: 这是我的xml:

<field name="titre"/>

I do not believe this functionality exists. 我不相信这个功能存在。 Someone can correct me if I am wrong. 如果我错了,有人可以纠正我。 What you could do however is use a computed select field. 但是,您可以使用计算的选择字段。 You may want to incorporate context variables to determine what select options need to be displayed. 您可能希望合并上下文变量以确定需要显示哪些选项。 This can be accomplished like so. 这可以这样完成。

@api.multi
def _compute_selection(self):
    if True:
        selection_options = [('e', 'Email'), ('p', 'phone'), ('m','Post/Mail')]
    else:
        selection_options = [('a', 'Automatic Action')]
    return selection_options

field_name = fields.Selection('_compute_selection', string="Field Name")

Obviously your compute function will have to flesh out the particulars. 显然,你的计算功能必须充实细节。 However basically you will want to compute your selection list rather than define it statically. 但是,基本上您需要计算选择列表而不是静态定义它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM