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

v17: inherit VIEW , custom module code is not working...

Subscribe

Get notified when there's activity on this post

This question has been flagged
viewinheritancecustommodulev17
1 Reply
4725 Views
Avatar
SmithJohn45

created model to inherit res.users and added 'supervisor' field and i can see this field in pgAdmin and also in Settings ->Technical -> Fields

i am trying to add 'supervisor' in user's form, please check below 2 screenshots, what am i doing wrong here? the inherited Users form not showing my custom field 'supervisor' after partner_id ( Related Partner in below form ). note i have added view file name in manifest file, also added 'base' in manifest file, then start server with upgrade the module using -u custom_module -d db_17 



plesae help.

regards

0
Avatar
Discard
Avatar
Ray Carnes (ray)
Best Answer

The field PARTNER_ID appears twice in the View you are inheriting.

Your field is being added after the FIRST occurrence, which will be hidden unless the User is archived and the Contact is not:

You want to add it after the SECOND occurrence.

See https://www.odoo.com/forum/help-1/select-multiple-elements-with-xpath-116090


You may be misunderstanding the Odoo data model - a User is a set of credentials and access rights - it is not an Employee.

The Employee App already has a Manager:




0
Avatar
Discard
SmithJohn45
Author

thank you @Ray for reply.
yes, Manager is exist but the requirement is what i am trying to implement.

i have modified code (as per what i understand from link provided) but it is still not showing on user's form view, please check what i am missing or doing wrong here.

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Define a new view for inherited model -->
<record id="view_custom_res_user_form" model="ir.ui.view">
<field name="name">custom.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id'][1]" position="after">
<xpath expr="//field[@name='partner_id'][2]" position="after">
<field name="supervisor"/>
</xpath>
</xpath>
</field>
</record>
</odoo>

regards

SmithJohn45
Author

The error in Odoo.log file as below:

Error while parsing or validating view:

Element '<xpath expr="//field[@name=&#39;partner_id&#39;][2]">' cannot be located in parent view

View error context:
{'file': 'd:\\program files\\odoo '
'17.0.20240101\\server\\odoo\\custom_addons\\brb_customizations\\views\\res_users_view.xml',
'line': 2,
'name': 'custom.res.users.form',
'view': ir.ui.view(1338,),
'view.model': 'res.users',
'view.parent': ir.ui.view(162,),
'xmlid': 'view_custom_res_user_form'}

.

SmithJohn45
Author

sorry @Ray, by mistake i posted above error in Odoo.log please ignore it, it was because of before my posted code in your reply.

SmithJohn45
Author

my first Comment to your Answer is valid, the 2nd one in which i posted error in Odoo.log is not.
waiting for your reply on my first Comment.
regards

Ray Carnes (ray)

In your first comment, you have an xpath inside an xpath and this is not supported.

If you wish to place your field after the second partner_id just reference the second partner_id - you don't need to reference the first at all

SmithJohn45
Author

@Ray
i have check with code below, its not even start Odoo Server and showing errors in odoo.log file as below:
-------
Element '<xpath expr="//field[@name=&#39;partner_id&#39;][2]">' cannot be located in parent view

View error context:
{'file': 'd:\\program files\\odoo '
'17.0.20240101\\server\\odoo\\custom_addons\\brb_customizations\\views\\res_users_view.xml',
'line': 3,
'name': 'custom.res.users.form',
'view': ir.ui.view(1338,),
'view.model': 'res.users',
'view.parent': ir.ui.view(162,),
'xmlid': 'view_custom_res_user_form'}
--------

modified code as per your instruction:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Define a new view for inherited model -->
<record id="view_custom_res_user_form" model="ir.ui.view">
<field name="name">custom.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id'][2]" position="after">
<field name="supervisor"/>
</xpath>
</field>
</record>
</odoo>

please advice and help.
regards

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
Customizing the save manually button Solved
inheritance v17
Avatar
Avatar
Avatar
2
Oct 24
3409
How to change the button display name via inherit Solved
inheritance v17
Avatar
Avatar
2
Jun 24
2313
v17: while installing on Live it throws error The module cannot be downloaded
custommodule v17
Avatar
0
Jan 24
2515
View inheritance Solved
view inheritance
Avatar
Avatar
1
Mar 20
4317
How do I remove fields from a view in a custom module? Solved
view inheritance
Avatar
Avatar
Avatar
Avatar
12
Dec 18
36142
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