Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

[v 14] Hide Smart buttons in contact form (res.partner)

Subscribe

Get notified when there's activity on this post

This question has been flagged
res.partnerhidev14smartbuttonextended
3 Replies
4795 Views
Avatar
Walter Gabriele

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.  

0
Avatar
Discard
Avatar
Waleed Ali Mohsen
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>


1
Avatar
Discard
Waleed Ali Mohsen

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>

Avatar
Jainesh Shah(Aktiv Software)
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

0
Avatar
Discard
Jainesh Shah(Aktiv Software)

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>

Avatar
Walter Gabriele
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

0
Avatar
Discard
Walter Gabriele
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>

Walter Gabriele
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.

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

Waleed Ali Mohsen

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>

Walter Gabriele
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.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to hide customers from sales persons in Odoo 14 Solved
res.partner v14
Avatar
Avatar
1
May 22
4332
ver.14: category_id in res.partner - confusing or something wrong Solved
res.partner v14
Avatar
Avatar
1
Mar 21
6550
Odoo 14: res.partner.category __ name of view (xml) file and act window entry to call from custom menu.
res.partner v14
Avatar
0
Jan 21
3672
customer field removed on res.partner when upgrading from odoo 12 to 14 Solved
res.partner odoo12 v14
Avatar
Avatar
1
Apr 23
3480
Access 'other' address country code
res.partner v14 clients
Avatar
0
Sep 22
3048
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now