Odoo Help

0

Remove button when inherit a view

By
Francisco Castro
on 12/23/14, 5:38 AM 5,824 views

Hey

I have a problem that I cant resolve

I want to remove the button "Imprimir" (Print) on the sale orders I just did all like

<xpath expr="//button[@name='invoice_print']" position="replace">
                 <!--add sometihng-->

</xpath>

or

<button name="invoice_print" string="Print" type="object" attrs="{'invisible':['|',('sent','=',True), ('state', '!=', 'open')]}" class="oe_highlight" groups="base.group_user" position="replace">
                  <!--add something-->

</button>

or 

 <xpath expr="//button[@name='invoice_print']" position="attributes">
                <attribute name="invisible">1</attribute>
              </xpath>

And none of those remove the button....

What I did wrong?

 

Best Regards

 

my code is this 

<record model="ir.ui.view" id="account_invoice_rule_saft_inherit">
            <field name="name">account.invoice.rule.saft.inherit</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
            <field name="arch" type="xml">
        <header>
              <!--<button name="invoice_print" string="Print" type="object" attrs="{'invisible':['|',('sent','=',True), ('state', '!=', 'open')]}" class="oe_highlight" groups="base.group_user" position="replace">
                  
              </button>-->
              <!--<xpath expr="//button[@name='invoice_print']" position="attributes">
                <attribute name="invisible">1</attribute>
              </xpath>-->
              <xpath expr="//button[@name='invoice_print'][0]" position="attributes">
                <attribute name="invisible">True</attribute>
              </xpath>
              <xpath expr="//button[@name='invoice_print'][1]" position="attributes">
                <attribute name="invisible">True</attribute>
              </xpath>

                 <button name="print_original" type="object" string="Original" attrs="{'invisible':['|','|',('impressoori', '=', True),('impressoall', '=', True),('state','=','draft')]}"/>

                <button name="print_duplicado" type="object" string="Duplicado" attrs="{'invisible':['|','|',('impressodupl', '=', True),('impressoall', '=', True),('state','=','draft')]}"/>  

                <button name="print_triplicado" type="object" string="Triplicado" attrs="{'invisible':['|','|',('impressoall','=',True),('impressotri','=',True),('state','=','draft')]}"/>

                <button name="print_all" type="object" string="Todas as Vias" attrs="{'invisible':['|','|','|','|',('impressoall', '=', True),('impressoori', '=', True),('impressodupl', '=', True),('impressotri', '=', True),('state','=','draft')]}" />

                <button name="print_segunda_via" type="object" string="Segunda Via" attrs="{'invisible':['|',('impressoseg', '=', True),('state','=','draft')]}" />
                
            </header>
        <notebook colspan="4" position="after">
            
        <group col="1">
                <field name="impressodupl" nolabel="0" invisible="1" />
                <field name="impressoori" nolabel="0" invisible="1" />
                <field name="impressotri" nolabel="0" invisible="1" />
                <field name="impressoall" nolabel="0" invisible="1" />
          <field name="impressoseg" nolabel="0" invisible="1" />
          
        </group>
           
          </notebook>
               </field>
        </record>

hum... didnt work my xml code is: account.invoice.rule.saft.inherit account.invoice account.invoice.rule.saft.inherit account.invoice

<xpath expr="//button[@name='invoice_print']" position="replace"/> <xpath expr="//button[@name='invoice_print']" position="replace"/>

Francisco Castro
on 12/23/14, 6:43 AM
3

FIRST, your FORM inheritance is wrong.  

Since there are 2 buttons available at Account Invoice Form https://github.com/odoo/odoo/blob/8.0/addons/account/account_invoice_view.xml#L297

METHOD-1:
So replace button twice in your inherited view.
<record id="account_invoice_form_inherit" model="ir.ui.view">
    <field name="name">account.invoice.form.sciencefirst</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_form"/>
    <field name="arch" type="xml">
        <xpath expr="//button[@name='invoice_print']" position="replace"/>
        <xpath expr="//button[@name='invoice_print']" position="replace"/>

    </field>
</record>

METHOD-2:
<record id="account_invoice_form_inherit" model="ir.ui.view">
    <field name="name">account.invoice.form.sciencefirst</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_form"/>
    <field name="arch" type="xml">
</record>
<xpath expr="//button[@name='invoice_print'][1]" position="attributes">
    <attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//button[@name='invoice_print'][2]" position="attributes">
    <attribute name="invisible">True</attribute>
</xpath>

    </field>
 

the First one dindt do nothing the second one it appears two labels on the Header "True" "True" the button Print is on the same place it just added two new fields on the header

Francisco Castro
on 12/23/14, 6:46 AM

Sorry, I provided code for Account Invoice instead of Sales order. I have corrected the code. Please check it.

Atchuthan - Technical Consultant, Sodexis Inc
on 12/23/14, 6:59 AM

but I think my question is on the account invoice

Francisco Castro
on 12/23/14, 7:06 AM

please provide correct description "I want to remove the button "Imprimir" (Print) on the sale orders I just did all like"??

Atchuthan - Technical Consultant, Sodexis Inc
on 12/23/14, 7:12 AM

I just try all I know and then I said my tries :) sorry

Francisco Castro
on 12/23/14, 7:15 AM

no problem

Atchuthan - Technical Consultant, Sodexis Inc
on 12/23/14, 7:16 AM

ok I did the 1st method and it worked thx for the pacience :)

Francisco Castro
on 12/23/14, 7:23 AM

patience*

Francisco Castro
on 12/23/14, 7:24 AM

Thanks, Atchuthan

+1

Ankit H Gandhi(AHG)
on 5/22/17, 8:27 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 12/23/14, 5:38 AM
Seen: 5824 times
Last updated: 3/16/15, 8:10 AM