Odoo Help


Is it possible to have two onchange methods for the same field?

Diego Calzadilla
on 4/2/15, 4:38 PM 612 views


Once I select a field, I need to fetch values from different tables and populate other fields: is it possible to have something like:

<field name="cm_id" on_change="on_change_cm_id(cm_id)" on_change="on_change_cm_id_2(cm_id)"/>

in my xml definition?

Thanks for suggestions!!

Diego Calzadilla
On 4/3/15, 12:10 AM

I answer my own question: This is no possible.

I manage to solve it in single on_change method, merging two dictionaries with values from different tables:

def on_change_cm_id(self,cr, uid, ids,cm_id,context=None):

     context=context or {} 

     application_data_product_template = []

     attributes_product_template = []

     value = {}

     dict = {}

     if ids:

             application_ids = self.pool.get('product.template.application.data.line').search(cr, uid,[('product_template_id','in',ids)])

             self.pool.get('product.template.application.data.line').unlink(cr, uid, application_ids)

             old_note_ids = self.pool.get('product.attribute.line').search(cr, uid,[('product_tmpl_id','in',ids)])

             self.pool.get('product.attribute.line').unlink(cr, uid, old_note_ids)

     application_cm_ids = []

     attribute_cm_ids = []

     attribute_cm_ids = self.pool.get('attribute.comun.denominador.line').search(cr, uid, [('comun_denominador_id', '=', cm_id)])

     application_cm_ids = self.pool.get('cm.application.data.line').search(cr, uid, [('comun_denominador_id', '=', cm_id)])

    for application_id in self.pool.get('cm.application.data.line').read(cr, uid, application_cm_ids, ['brand', 'date_beg', 'dateend', 'model']):

          application_data_product_template.append((0,0,{'brand':application_id['brand'][0],'date_beg':application_id['date_beg'], 'dateend':application_id['dateend'], 'model':application_id['model'][0]}))


    for attribute_id in self.pool.get('attribute.comun.denominador.line').read(cr, uid, attribute_cm_ids, ['attribute_comun_denominador_id', 'value_comun_denominador_ids']):



    value.update(dict)#in this part, dictionaries are merged!!

    return {'value':value}

Hope this is helpful for someone!!

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: 4/2/15, 4:38 PM
Seen: 612 times
Last updated: 4/3/15, 12:10 AM