Odoo Help


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.


How to copy the value of one field to another on client side ..?

Nishant Kashyap
on 5/23/13, 4:16 AM 1,858 views

Hi, I have a char field name home_number and a Boolean field same_as_above and a char field name present_number, I was looking foe something, as I click the same_as_above field I want to copy the above value i.e home_number to the char field present_number.

Can I achieve this in Openerp V7 in views(XML). ..?

On 5/29/14, 5:24 AM

Thanks for reply, I want when boolean field is True, then copy the value . In on_change I can use the values from the database , but I cant use the values that are on views , before saving the form ....

Nishant Kashyap
On 5/23/13, 5:12 AM

Okay I got the answer. In .py file

class MyFields(osv.osv):
         'home_number':fields.char('Home Number',size=100),
         'present_number':fields.char('Present Number',size=100)
def onchange_same_as_above(self,cr, uid, ids,same_as_above,home_number,context=None):
    if same_as_above:
        return {'value':{'present_number':home_number,}}
    return {'value':{}}

In XML file

<field name="home_number"/>
<field name="same_as_above" on_change="onchange_same_as_above(same_as_above,present_number)"/>
<field name="present_number"/>


| 5 4 7
Baarn, Netherlands
On 5/23/13, 4:22 AM

You want to use the boolean field to behave like a button?

To answer your question: No you cannot do this in XML (only). You need to write some code, and link that code to the field (probably on_change_<name field="">). The linking is done in XML, but the code in your custom python module.

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

0 follower(s)


Asked: 5/23/13, 4:16 AM
Seen: 1858 times
Last updated: 3/16/15, 8:10 AM