Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
8 Відповіді
43192 Переглядів

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

Найкраща відповідь

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

Аватар
Відмінити
Найкраща відповідь

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.


Аватар
Відмінити
Найкраща відповідь

Try use this:

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

Аватар
Відмінити
Найкраща відповідь

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>

Аватар
Відмінити

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)

Найкраща відповідь

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.

Автор

It will hide old form fields too ?

Related Posts Відповіді Переглядів Дія
3
квіт. 21
7800
2
черв. 20
5187
1
жовт. 19
4239
0
жовт. 17
2712
1
бер. 15
13388