【问题标题】:Hide field in one2many_field隐藏 one2many_field 中的字段
【发布时间】:2015-11-10 08:56:20
【问题描述】:

我有one2many 字段和one2many_list tag,我想隐藏qty 字段,如果我选择例如service,则不需要该字段。

我认为有这段代码:

<field name='type'/>

<field name="products" nolabel="1" widget="one2many_list">
    <tree editable="bottom" >
        <field name='description'/>
        <field name='qty'/>
        <field name='total'/>
    </tree>
</field>

如何使用type 字段来做到这一点?

【问题讨论】:

    标签: xml view openerp


    【解决方案1】:

    您可能想要使用attr 标签。

    attrs="{'invisible': [('type','=','service')]}"
    

    this will hide the field when the chosen type equals service

    由于该字段不在同一模型上,您可以在 one2many 字段的模型上创建一个功能字段,您可以在其中检查是否需要隐藏 qty 字段

    【讨论】:

    • 我收到此错误:Runtime Error: Error: Unknown field type in domain [["type","=", true]]
    • 您不能根据另一个字段有条件地隐藏树中的字段。
    • 抱歉,我认为该字段在同一个模型中。编辑了我的答案
    猜你喜欢
    • 2013-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-25
    • 2011-01-02
    • 2012-05-17
    • 1970-01-01
    相关资源
    最近更新 更多