Odoo Help

Welcome!

This community 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.

0

Remove button when inherit a view

By
Francisco Castro
on 12/23/14, 5:38 AM 3,838 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
1

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 12/23/14, 6:24 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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