Odoo Help

Welcome!

This community 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.

0

How to replace a field in a XML record? [SOLVED]

By
Yannick Gerard
on 5/4/15, 3:38 AM 1,497 views

Hello everybody,

I want to replace a field in a XML record, but obviously, what I tried doesn't seem to be the good way to do it ... here's my record:


<record model="ir.actions.act_window" id="open_allocation_holidays">

<field name="name">Allocation Requests</field>

<field name="res_model">hr.holidays</field>

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

<field name="context">{'default_type':'add', 'search_default_my_leaves':1}</field>

<field name="domain">[('type','=','add')]</field>

<field name="view_id" ref="allocation_leave_new"/>

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

</record>


What I want is to replace the field to add a default filter.

<field name="context">{'default_type':'add', 'search_default_my_leaves':1}</field>

with:

<field name="context">{'default_type':'add', 'search_default_my_leaves':1, 'search_default_my_validations':1}</field>


I already tried xpath with position="attributes" and position="replace,

<xpath expr="//record[@id='open_allocation_holidays' ]" position="attributes"> <attribute name="context"> {default type ...}</attribute></xpath>, I tried to search with the field name too (expr="//field[@name='context']") but nothing works.
Is there an other way to replace my field ?


1
Bipin rathod
On 5/4/15, 4:42 AM

Hello, 

This is an action so you just need to use same id and write it again the same action.

This is the simple way to use and add in existing action.

Ex.

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

<field name="name">Allocation Requests</field>

<field name="res_model">hr.holidays</field>

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

<field name="context">{'default_type':'add', 'search_default_my_leaves':1, 'search_default_my_validations':1}</field>

<field name="domain">[('type','=','add')]</field>

<field name="view_id" ref="allocation_leave_new"/>

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

</record>


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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 5/4/15, 3:38 AM
Seen: 1497 times
Last updated: 8/30/15, 9:50 AM