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

how to replace or override form view in xml

Subscribe

Get notified when there's activity on this post

This question has been flagged
xmlxpathodoo9.0
8 Replies
46084 Views
Avatar
Silviaa

I'm customizing Invoice task window in odoo 9

My existing form

<record id="view_account_analytic_account_form" model="ir.ui.view">

<field name="name">analytic.analytic.account.form</field>

<field name="model">account.analytic.account</field>

<field name="arch" type="xml">

<form string="Analytic Account">

<sheet string="Analytic Account">

<field name="name" class="oe_inline" placeholder="e.g. Project XYZ"/>

<group>

<field name="account_type" invisible="1"/>

<field name="partner_id"/>

</group>

<group>

<field name="code"/>

<field name="tag_ids" widget="many2many_tags"/>

<field name="company_id"/>

<field name="currency_id"/>

</group>

</sheet>

</form>

</field>

</record>

Instead of above form I want to replace as below

<form string="Analytic Entry">

<sheet>

<group>

<group>

<field name="name" />

</group>

<group>

<field name="date" />

<field name="ref" />

<field name="company_id" groups="base.group_multi_company" />

</group>

<group string="Product Information">

<field name="product_id" domain="[('name_template','=','Service')]" />

<label for="unit_amount" />

<div>

<field name="unit_amount" class="oe_inline" />

<field name="product_uom_id" class="oe_inline" />

</div>

</group>

</group>

</sheet>

</form>

I tried with

 <xpath expr="//form[@string='Analytic Account']" position="replace" >

 <form>

<!-- my form view -->

</form>  </xpath>

 I don't want to replace my fileds I just want to replace my full form view by using id

can anyone please help me ?

1
Avatar
Discard
Premananth

Yes it will overwrite the existing form view

Avatar
Hilar Andikkadavath
Best Answer

HI,

To override the xml views, you just need to make exact id of view to be override following the modelname ie, id="modelname.id".

That will replace your previous view with the custom one .

Thanks

4
Avatar
Discard
Avatar
Wahab Ali Malik
Best Answer

Sorry for lateness But i think this is still an Issue and all above answer are not good.

If you want to completely replace a form.then you have to follow these steps.

1-Write your new form.

2- If you are not creating new action then skip this step otherwise write your action.

                <record id="module_name.action_all_owners"  model="ir.actions.act_window">

                        <field name="name">All Owners</field>

                        <field name="type">ir.actions.act_window</field>

                        <field name="res_model">res.partner</field>

                        <field name="view_type">form</field>

                        <field name="view_mode">tree,form</field>

                        <field name="context">{'search_default_customer':1,'default_owner':1}</field>

                        <field name="search_view_id" ref="view_res_partner_filter"/>

                        <field name="domain" eval="[('customer', '=', True)]"/>

                        <field name="help" type="html">

                                <p class="oe_view_nocontent_create">

                                        Click to add a contact in your address book.

                                </p>

                        </field>

                 </record>

3-If Action already exist or you write above action, define each view type you write in main action type.like


<record id="module_name.action_all_owners_tree" model="ir.actions.act_window.view">

    <field eval="1" name="sequence"/>

    <field name="view_mode">tree</field>

    <!--<field name="view_id" ref="module_name.view_partner_tree"/> -->

    <field name="act_window_id" ref="module_name.action_all_owners"/>

</record>


<record id="module_name.action_all_owners_form" model="ir.actions.act_window.view">

    <field eval="2" name="sequence"/>

    <field name="view_mode">form</field>

    <field name="view_id" ref="module_name.view_partner_form"/> 

    <field name="act_window_id" ref="module_name.action_all_owners"/>

</record>


ID -Must be unique.

eval - Sequence of view type 

view_mode - [form,tree,kanban,etc..]

view_id - ID of new form or tree view you want to replace.

act_window_id - ID of main action on which you want to perform stuff

IMPORTANT ::If you just want to add one new view type like form but not want to disturb sequence then write tree and kanban view with out view_id as you can see in tree view action i just comment view_id so it just only update form view without disturbing view sequence.


1
Avatar
Discard
Avatar
Dachi Darchiashvili
Best Answer

Try use this:

<xpath expr="//form" position="replace">

0
Avatar
Discard
Avatar
Mehul Patel
Best Answer

first you just need to give id of view that you want to override in model.

<record id='view_account_analytic_account_form' model='ir.ui.view'>

<field name="name">account.analytic.account.form</field>

<field name="model">account.analytic.account</field>

<field name="type">form</field>

<field name="inherit_id" ref="account.view_form_id"/> // give (view_from_id ) Id of Form View to override form view

<field name="arch" type="xml">

<data> <xpath expr="//form" position="replace">

</xpath> 

</data>

</field>

</record>

0
Avatar
Discard
Levi Bensley

I tried this, but for the sale view, but then couldn't update the base sale module or modules such as sale_purchase do to a missing field (one that i added in my custom module)

Avatar
Premananth
Best Answer

Hi Silviaa


<record id="analytic.view_account_analytic_account_form" model="ir.ui.view">

<field name="name">analytic.analytic.account.form</field>

<field name="model">account.analytic.account</field>

<field name="arch" type="xml">

    please place your code

</field>

</record>

0
Avatar
Discard
Premananth

I hope this will help you.

Silviaa
Author

It will hide old form fields too ?

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 select an <xpath> element?
xml xpath
Avatar
Avatar
Avatar
Avatar
3
Apr 21
9560
How to add notebook via xpath Solved
xml xpath
Avatar
Avatar
2
Jun 20
6484
how i can use xpath for notebook in odoo 12 ? Solved
xml xpath
Avatar
Avatar
1
Oct 19
5296
How to add image on each page in account invoice report in odoo9 ?
xml odoo9.0
Avatar
0
Oct 17
3621
why xml code causing Unfinished literal error? Solved
xml xpath
Avatar
Avatar
1
Mar 15
14684
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