【问题标题】:How to make a button invisible under some conditions on an Odoo view?如何在 Odoo 视图的某些条件下使按钮不可见?
【发布时间】:2015-08-16 11:26:54
【问题描述】:

我想在树视图中添加一个按钮,并且我想在purchase_line_id 为 NULL 时使其不可见。

我该怎么做?以下是我的视图继承代码。

<record id="view_move_pickingextended_tree" model="ir.ui.view">
            <field name="name">stock.move.tree.extended</field>
            <field name="model">stock.move</field>
            <field name="inherit_id" ref="stock.view_move_picking_tree"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='state']" position="after">
                    <button name="%(uom_conv_trans_level_thura)d" string="Manual Pick"
                            type="action" class="oe_highlight" icon="fa-book"
                            context="{'product_id':product_id}" invisible="context.get('purchase_line_id',False)"/>
            </xpath>
        </field>
    </record>

【问题讨论】:

  • 该字段仅在上下文中?

标签: xml odoo-8 odoo odoo-view


【解决方案1】:

试试吧

<button name="%(uom_conv_trans_level_thura)d" string="Manual Pick"
        type="action" class="oe_highlight" icon="fa-book"
        context="{'product_id':product_id}"
        attrs="{'invisible': [('purchase_line_id', '=', False)]}" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-13
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多