[英]odoo xml - hide two buttons with same attribute - on condition
I've added a new boolean field(with default False) to the sale_order and added a button to set it as True in the quotation form.我在 sale_order 中添加了一个新的布尔字段(默认为 False),并添加了一个按钮以在报价单中将其设置为 True。
<button name="action_confirm" position="before">
<field name="boolean_field" invisible="1"/>
<button name="set_boolean_field" string="Boolean Field" type="object"
attrs="{'invisible': ['|',('boolean_field', '=', True), ('state','in',('sale','confirm'))]}"/>
</button>
Now, I need to hide the "Confirm Sale" button, when the above boolean field is False, in the quotation form.现在,当上述布尔字段为 False 时,我需要在报价单中隐藏“确认销售”按钮。
There are two such buttons in the form header.表单标题中有两个这样的按钮。
<button name="action_confirm" states="sent" string="Confirm Sale" class="btn-primary o_sale_confirm" type="object"/>
<button name="action_confirm" states="draft" string="Confirm Sale" class="o_sale_confirm" type="object"/>
How do I hide the above two buttons when based on the value of boolean_field?基于boolean_field的值如何隐藏上面的两个按钮?
Thanks.谢谢。
I can't test it but I think it should be something like that.我无法测试它,但我认为它应该是这样的。
It needs the boolean_field
first.它首先需要boolean_field
。
It replaces first and second buttons attrs field.它替换了第一个和第二个按钮 attrs 字段。 If the original buttons already have something in the attrs field then it should be added to here aswell.如果原始按钮在 attrs 字段中已经有一些东西,那么它也应该添加到这里。
<xpath expr="//button[@name='action_confirm'][1]" position="attributes">
<attribute name="attrs">{'invisible': [('boolean_field', '=', False)]}</attribute>
</xpath>
<xpath expr="//button[@name='action_confirm'][2]" position="attributes">
<attribute name="attrs">{'invisible': [('boolean_field', '=', False)]}</attribute>
</xpath>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.