Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
3 Antworten
3547 Ansichten

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
Verwerfen
Beste Antwort

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
Verwerfen

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>

Beste Antwort

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
Verwerfen

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>

Autor Beste Antwort

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

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>

Autor

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.

Autor

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

Autor

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.

Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Mai 22
3224
1
März 21
4636
0
Jan. 21
2282
1
Apr. 23
1800
0
Sept. 22
1953