Skip to Content
Menu
This question has been flagged

I am trying to hide the smart buttons in the upper right of res.partner, I have succeeded for two of these, but for others it reports me an error like The element

xpath expr = "// form // sheet // div [1] // button [@ name = '641'] "

 />cannot be located in the parent view

this is my code:

i can't attach my code why?

i'm try to explain more:

    this is my inherited view from model res.partner with inerit_id and ref as base. view_partner_form


my xpath call is to form-sheet-div[1]-button[1] - this work

my second xpath call is to button[@name='action_view_partner_invoices' - this work

my other xpath like form - sheet - div[1] - button[@name='%(purchase.act_res_partner_2_purchase_order)d'] - not work

thanks.  

Avatar
Discard
Best Answer

Hi,

If you want to hide all smart button in the res.partner form you can add invisible attribute to div with name "oe_button_box".

To hide purchase Order button:

<record id="res_partner_view_purchase_buttons_inherit" model="ir.ui.view">
<field name="name">res.partner.view.purchase.buttons.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="purchase.res_partner_view_purchase_buttons"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(purchase.act_res_partner_2_purchase_order)d']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>


Avatar
Discard

To hide purchase order button use the below:

<record id="res_partner_view_purchase_buttons_inherit" model="ir.ui.view">
<field name="name">res.partner.view.purchase.buttons.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="purchase.res_partner_view_purchase_buttons"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(purchase.act_res_partner_2_purchase_order)d']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>

Best Answer

Hello Walter Gabriele,

It is wrong xpath “button[@name='%(purchase.act_res_partner_2_purchase_order)d']”

You can use attributes in XML and give d-none class.

Inherit “res_partner_view_purchase_buttons” from view then try to this xpath


Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard

Inherit “res_partner_view_purchase_buttons” from view then try to this xpath
<xpath expr=”//div[@name=”button_box]/button” position=”attributes”>
<attribute name="class" add="d-none" separator=" "/>
</xpath>

Author Best Answer

Thank for your answer Waleed Mohsen but i don't wont hide all because the buttons I want to add to view would also be hidden

Avatar
Discard
Author

hi Jainesh,
maibe something wrong?
<record id="res_partner_view_purchase_buttons_inherited" model="ir.ui.view">
<field name="name">res.partner.view.purchase.buttons.inherited</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="purchase.res_partner_view_purchase_buttons" />
<field name="arch" type="xml">
<xpath expr="//div[@name=”button_box]/button" position="attributes">
<attribute name="class" add="d-none" separator=""/>
</xpath>
</field>
</record>

Author

thank you Waleed Mohsen i've tried many of this but this is the error when i update my module:
the field "purchase_order_count" not exist in model "res.partner"

I don't know what I can think anymore.

Author

<record id="res_partner_view_purchase_buttons_inherit" model="ir.ui.view">
<field name="name">res.partner.view.purchase.buttons.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="purchase.res_partner_view_purchase_buttons"/>
<field name="arch" type="xml">
<!-- <xpath expr="//button[@name='%(purchase.act_res_partner_2_purchase_order)d']" position="attributes">-->
<!-- <attribute name="invisible">1</attribute>-->
<!-- </xpath>-->
<xpath expr="//div[@name='button_box']/button" position="attributes">
<attribute name="class" add="d-none" separator=" "/>
</xpath>
</field>
</record>

same result alwais

I have tested the below code locally and it's working without any issue.

<record id="res_partner_view_purchase_buttons_inherit" model="ir.ui.view">
<field name="name">res.partner.view.purchase.buttons.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="purchase.res_partner_view_purchase_buttons"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(purchase.act_res_partner_2_purchase_order)d']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>

Author

HI Waleed Mohsen, i don't know why, your suggestion works it's ok so +1, but i had to fix my python code in custom model like this for it to work:

class PartnerInherit ( models.Model ):
_inherit = 'res.partner'
purchase_order_count = fields.Integer(store=False)
purchase_warn = fields.Char(store=False)
purchase_warn_msg = fields.Text(store=False)
on_time_rate = fields.Float(store=False)
sale_order_count = fields.Integer(store=False)
sale_warn = fields.Char(store=False)
sale_warn_msg = fields.Char(store=False)
supplier_invoice_count = fields.Integer(store=False)

Thanks for your support.

Related Posts Replies Views Activity
1
May 22
2692
1
Mar 21
3946
0
Jan 21
1872
1
Apr 23
1306
0
Sep 22
1492