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

odoo9: How to change the position of a field and apply an onchange on it?

By
Drees Far
on 4/29/16, 4:38 AM 454 views

Hello Guys!!!

I want to change the position of the field job_id in the hr_contract form.

So that, i tried this:

  <xpath expr="//field[@name='job_id']" position="attributes">

<attribute name="invisible">True</attribute>

</xpath>

and then:

   <xpath expr="//field[@name='job_id']" position = "replace">

       <field name="job_id" string="Fonction"/>

</xpath>

But when i try to apply an onchange on it, nothing happend :/

Can anyone help me to know how to change its position please.

Thaks a lot in advance.

Best Regards.

1

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 4/29/16, 10:18 AM

Hi Drees,

Actually when you are replacing the field, its getting replaced correctly, but the new field is not having any "onchange" event associated with it.

Thats why on change is not triggering.

So, Just replace the field with the previous one and check out the onchange attribute in original field and keep that in new one too.

<xpath expr="//field[@name='job_id']" position = "replace">

       <field name="job_id" string="Fonction" onchange="<function in original field>"/>

</xpath>


Hope it helps

1
Krutarth Buch
On 4/29/16, 5:15 AM

Hello,

If you want to change position of a field then don't use invisible attribute.It will only invisible that field.

You applied attrs="invisible" and also added field on a position where you want. So field is there in form view 2 times which causes the problem. So instead of position="attribute" , replace it with blank.

Then add field where you want to add and apply onchange.

<xpath expr="//field[@name='job_id']" position="replace"> 

</xpath>

<xpath expr="//path_where_you_want_to_add_field" position="after"> 

 <field name="job_id" string="Fonction" on_change="your_onchange_method"/>

</xpath>

Thanks

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

1 follower(s)

Stats

Asked: 4/29/16, 4:38 AM
Seen: 454 times
Last updated: 4/29/16, 10:18 AM