Skip to Content
Menu
This question has been flagged
8 Replies
29609 Views

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
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

Avatar
Discard
Author

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

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

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.

Avatar
Discard

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

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>


Avatar
Discard
Author

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

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

Author

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

Related Posts Replies Views Activity
1
Mar 17
2135
2
Dec 22
1715
2
Jun 21
3833
4
Mar 17
7320
1
May 16
6756