Help

0

Hide or remove button added by xpath

Avatar
Nebil Aydi

I want to hide the 2 buttons on opportunity view : 'Create Quotation'  &  'Convert to Quotation' which are created by Xpath from sale_crm module:

<xpath expr="//field[@name='stage_id']" position="before">
<button attrs="{'invisible': [('probability', '&lt;', 100)]}" string="Create Quotation" name="618" type="action"/>
<button attrs="{'invisible': [('probability', '=', 100)]}" string="Convert to Quotation" name="618" type="action" class="oe_highlight"/>
</xpath>

how Can I do it ..??

Avatar
Discard
3 Answers
1
Avatar
Niyas Raphy
Best Answer

Hi,

Below shown is just a sample of how to make a button invisible using xpath,

<record id="product_supplierinfo_form_view_inherit" model="ir.ui.view">    
<field name="name">product.supplierinfo.form.inherit</field>
<field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
<field name="arch" type="xml">
    <xpath expr="//button[@name='test_button']" position="attributes">
        <attribute name="invisible">1</attribute>
    
</xpath>
</field>
</record>

Check this and update yours accordingly.

Thanks

2 Comments
Avatar
Discard
Avatar
Nebil Aydi
-

these 2 buttons are created using xpath from sale_crm (default odoo module) module not implemented directly on opportunity form view ..

how can I hide them from my custom module

Avatar
Niyas Raphy
-

Then in the ref use the id of the previous xpath record id.

1
Avatar
Boubaker Abdallah
Best Answer

Hi Nebil 

You can do this change the  position="before" 

position="replace"
OR

<xpath expr="//button[@name='action_Create Quotation' and @states='draft']" position="attributes">
<attribute name="states" />
<!-- delete states attribute, it's influencing invisible behaviour -->
<attribute name="invisible">1</attribute>
</xpath>


3 Comments
Avatar
Discard
Avatar
Nebil Aydi
-

these 2 buttons are created using xpath from sale_crm (default odoo module) module not implemented directly on opportunity form view ..

how can I hide them from my custom module

Avatar
Boubaker Abdallah
-

salam nabil

You can better explain your need

you want to hide 2 buttons from which form

you can give us the source code or an image or link and the Version Odoo

Avatar
Nebil Aydi
-

This is my contact on Skype (aydi.nebil) .. Add me .. :)

1
Avatar
Sehrish
Best Answer

Position attribute have following values.

  1. position="after" : To display field after parent form view field mentioned in "expr"

  2. position="before" : To display field before parent form view field mentioned in "expr"

  3. position="inside" : To display field inside notebook of parent form view

  4. position="attributes" : To change field attribute such as read only and visibility of a field

  5. position="replace" : To replace parent form view field with your newly created field

You can use above attributes as per your need.

1 Comment
Avatar
Discard
Avatar
Sehrish
-

Here is complete code and description related to xpath, inheritance in views and model to modify existing model fields.

http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

Hope it may help you and others.

Thanks