跳至内容
菜单
此问题已终结
8 回复
31973 查看

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

形象
丢弃
最佳答案

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

形象
丢弃
编写者

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.

最佳答案

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.

形象
丢弃

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

最佳答案

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>


形象
丢弃
编写者

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

编写者

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

相关帖文 回复 查看 活动
0
12月 24
970
1
3月 17
2897
2
12月 22
3046
2
6月 21
5123
4
3月 17
8447