Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
36590 Vistas

Hello,

i am trying to hide a button in the header section of a form view:

<field name="arch" type="xml">
            <form string="Collect Order" version="7.0">
            <header>
                <button name="become_interested" states="draft, confirmed" string="Interest" type="object" attrs="{'invisible':[('interested','=',True)]}" class="oe_highlight" />
                <button name="lost_interested" states="draft, confirmed, price, pending" string="Lost Interest" type="object" class="oe_higlhight" attrs="{'invisible': [('interested','=',False)]}" />
                <button name="interest_to_buy" states="pending" string="Order" type="object" class="oe_highlight"/>
                <field name="state" widget="statusbar" nolabel="1" />
            </header>

Under attrs Tag the invisible doesn't work. Does i have a typo or programming error, i don't see?

Avatar
Descartar

how about modifying the CSS stylesheet?

Autor

but shouldn't it work this way? i had a look at accounting module, and there are also buttons made invisible this way...

Mejor respuesta

Use either states or attrs:

Your code:

<button name="become_interested" states="draft, confirmed" string="Interest" type="object" attrs="{'invisible':[('interested','=',True)]}" class="oe_highlight" />

Try using this code:

<button name="become_interested" string="Interest" type="object" attrs="{'invisible':['|','|',('interested','=',True),('state','!=','draft'),('state','!=','confirmed')]}" class="oe_highlight" />
Avatar
Descartar
Autor

will have a try this evening and answer. typo failure: type="object should be closed with " , right?

@Steinfeld, just add a double quotation at the end object like type="object"

Autor

Tried and verify with a little modification: <button name="become_interested" string="Interested" type="object" attrs="{'invisible':['|',('interested','=',True),('state','not in',['draft','confirmed'])]}" class="oe_highlight" />

Mejor respuesta

Try to add invisible="1" to the button you want to hide permanently. .%

Avatar
Descartar
Mejor respuesta

Hello Maik, I come to same problem for hiding a button in header button, Now i get solution, Here i share you. My scenario is to hide a print button in header when state is draft & sent. So i use attributes tag for this. Again i inherit button print once again. In base module already to 2 lines Please refer below, so i hide that 2 lines for my customized one.

    <button name="print_quotation" position = "attributes" > 
        <attribute name = "invisible">1</attribute>
    </button>

To Hide and Inherit a print button :

<xpath expr="//form/header/button[@name='action_quotation_send']" position="after"> <button name="print_quotation" string="Print" type="object" states="draft" class="oe_highlight" groups="base.group_user" invisible="1"/> <button name="print_quotation" string="Print" type="object" states="sent" groups="base.group_user" invisible="1"/> <button name="print_quotation" string="Print" type="object" class="oe_highlight" attrs="{'invisible': [('state','not in',('manual','progress'))]}" groups="base.group_user"/> </xpath>

I hope you may get some idea.. Thanks for your time

Vikram.V

Avatar
Descartar
Autor

did you see, that i marked the question as solved?