Reputation: 1402
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.
<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.
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?
Thanks.
Upvotes: 0
Views: 959
Reputation: 1590
I can't test it but I think it should be something like that.
It needs the boolean_field
first.
It replaces first and second buttons attrs field. If the original buttons already have something in the attrs field then it should be added to here aswell.
<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>
Upvotes: 1