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.


Create dynamic selection on many2one fields with onchange

on 7/2/15, 12:23 PM 823 views

This question is really close to this one :


My code so far:

the xml:

    field name="ds_id" on_change="onchange_fill_fields(ds_id)"

the method:

def onchange_fill_fields(self, cr, uid, ids, ds, context=None)

    res = {'value': {}}

    ds_domain = []

    ds_domain.append(('model_id', '=', model_name)) # model_name is the name of the model we have     chose('res.parnter',account etc)

return {'value': res.get('value', {}), 'domain': {'field_name': ds_domain}}

The problem is that I want with this function to change the selection to an other class.


    'first_obj': fields.one2many('second_obj', 'first_obj_id', string='models')

    'ds_id': fields.many2one('ds_obj', string='Data ', required=True), }

    (the ds_id is an other class, where there is a selection with models


Other class columns={

    'second_obj: fields.many2one('sec_obj', string='Camp'),

    'field_name': fields.many2one('ir.model.fields', 'Model Fields',

    domain=[('model_id', '=', ' ')]),


So if i pick res.partner(for example) from the selection (ds_id), I want to see the res.partner fields in a selection to the other class!Is this possible?? If it was in the same class,it would be easy.But this is different. I know that I have to change the "domain" to be like this

('model_id', '=', model_name)

Any Help?


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)


Asked: 7/2/15, 12:23 PM
Seen: 823 times
Last updated: 7/7/15, 9:04 AM