Odoo Help


how to replace or override form view in xml

on 9/1/16, 2:46 AM 4,557 views

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


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

<field name="partner_id"/>



<field name="code"/>

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

<field name="company_id"/>

<field name="currency_id"/>






Instead of above form I want to replace as below

<form string="Analytic Entry">




<field name="name" />



<field name="date" />

<field name="ref" />

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


<group string="Product Information">

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

<label for="unit_amount" />


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

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






I tried with

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


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

Yes it will overwrite the existing form view

on 9/2/16, 6:35 AM
--Hilar AK--



Hilar AK
On 11/10/16, 4:36 AM


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 .


Wahab Ali Malik
On 1/19/18, 10:48 AM

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.




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


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.

On 12/14/16, 12:57 AM

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





Dachi Darchiashvili
On 9/1/16, 3:12 AM

Try use this:

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

On 9/1/16, 4:27 AM

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



I hope this will help you.

on 9/1/16, 4:28 AM

It will hide old form fields too ?

on 9/2/16, 5:28 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 9/1/16, 2:46 AM
Seen: 4557 times
Last updated: 1/19/18, 10:56 AM