Skip to Content
Menu
This question has been flagged
1 Reply
5718 Views

This question is really close to this one :

https://www.odoo.com/forum/help-1/question/how-to-create-dynamic-domain-on-many2one-fields-with-onchange-function-11253

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.

columns={

    '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?

 

Avatar
Discard
Best Answer

Hi, 

You can follow following link for this:

https://youtu.be/GPhgxxwprA4

Hope it helps,

Thanks

Avatar
Discard
Related Posts Replies Views Activity
0
Dec 18
13
1
May 16
3906
3
Jul 24
3944
3
Mar 23
5766
1
Aug 22
6908