Odoo Help

0

how to replace or override form view in xml

By
Silviaa
on 9/1/16, 2:46 AM 908 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"/>

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

Yes it will overwrite the existing form view

Premananth
on 9/2/16, 6:35 AM
1

Hilar AK

--Hilar AK--
Hilar AK
849
| 5 3 8
Italy
--Hilar AK--


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

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

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

</xpath> 

</data>

</field>

</record>

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

Try use this:

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

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

</field>

</record>

I hope this will help you.

Premananth
on 9/1/16, 4:28 AM

It will hide old form fields too ?

Silviaa
on 9/2/16, 5:28 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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.

Register

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

1 follower(s)

Stats

Asked: 9/1/16, 2:46 AM
Seen: 908 times
Last updated: 12/14/16, 12:57 AM