Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
8 Odpovědi
31949 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor

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.

Nejlepší odpověď

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
Zrušit

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

Nejlepší odpověď

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
Zrušit
Autor

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

Autor

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

Related Posts Odpovědi Zobrazení Aktivita
0
pro 24
957
1
bře 17
2895
2
pro 22
3040
2
čvn 21
5120
4
bře 17
8433