Odoo Help


How to get old value using on_change method?

on 11/6/13, 8:43 AM 1,438 views

Hi everybody,

I have many2one partner_id and one2many recommendation_ids fields in my form view. I need to return old partner_id value if there are some records in recommendation_ids field.


<field name="partner_id" on_change="onchange_partner_id(partner_id, recommendation_ids)"/>
<field name="recommendation_ids" />


def onchange_partner_id(self, cr, uid, ids, partner_id, recommendation_ids, context=None):
    return {'value': old_partner_id}


Please explain it better. Thanks

GH Mediacloud, Grover Menacho
on 11/6/13, 10:55 AM
Prajul P T
On 11/6/13, 9:14 AM

Hi, onchange event does not save the result of the onchange function to the database. It is saved only when we click on the save button. So if you browse the current record and fetch the partner_id, it will fetch the older partner_id.

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.


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)


Asked: 11/6/13, 8:43 AM
Seen: 1438 times
Last updated: 3/16/15, 8:10 AM