0

I have created a button named 'Confirm' in customer invoice. When i click 'Confirm' button 'state1' will be 'confirmed'. I want to hide Validate button when 'state1'='draft' and show the Validate button when 'state1'='confirmed'. I tried below code but it is not working. Can anyone help me?

<!-- inherit account invoice form -->
    <record id="invoice_form_inheritai" model="ir.ui.view">
        <field name="name">account.invoice.form.inheritai</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_form"/>
        <field name="arch" type="xml">
            <button name="invoice_print" position="after">
                <field name="state1" invisible="1"/>
                <button name="invoice_check" string="Confirm" type="object"  attrs="{'invisible': [('state1','not in', ['draft'])]}" class="oe_highlight" groups="base.group_user"/>
            </button>
            <button name="invoice_open" position="replace">
                <button name="invoice_open" state="draft" string="Validate" attrs="{'invisible': [('state1','!=', ['confirmed'])]}" groups="base.group_user"/>
            </button>
        </field>
    </record>
sajadkk
  • 764
  • 1
  • 5
  • 19

2 Answers2

1
<button name="invoice_open" string="Validate" attrs="{'invisible': [('state1','not in', ['confirmed']),('state','not in',['draft'])]}" groups="base.group_user"/>

Please avoid using both invisible attribute and states.

OmaL
  • 5,037
  • 3
  • 31
  • 48
0

Try using 'states' instead of 'state'. And even attr won't be required. It will work automatically. Ex:

<button name="invoice_open" states="confirmed" string="Validate" groups="base.group_user"/>
Dharmraj
  • 576
  • 6
  • 26
  • i tried as you said...but it is still showing Validate button. I want to hide it until i click 'Confirm' button, which will change the 'state1' field into 'confirmed'. – sajadkk Feb 06 '14 at 10:23
  • oh den put states="confirmed". I've edited my answer as well. – Dharmraj Feb 06 '14 at 10:46
  • well it hides the validate button but it doesn't show when i click 'Confirm' button. i think i have to change the workflow – sajadkk Feb 06 '14 at 11:04