Odoo Help


Dymnamic many2one on onchnage

Praveen Upadhyaya
on 8/8/14, 5:43 AM 707 views

I have create a module real.project in that module a field is pr_block is many2many --> to a  block module

one other module flat. the flat module have two field ft_project --->many2one to real.project, and ft_block-->many2one to block class

Now I want to apply Domain to on ft_block such that when we select a project in flat module the ft_block will show only the blocks in that selected  project in ft_project field

    def on_change_project(self, cr, uid, ids, ft_project, context=None):
        res ={}
        res1 =[]
        block_obj = self.pool.get('blocks')

###########    List of ids to be displayed in the field many2one ft_block  
        block_ids = block_obj.search(cr,uid, [('re_project','=',ft_project)])
        res = {'domain': {'ft_block': [('id', 'in', block_ids)]}}
        return res

    _columns = {
            'ft_project':fields.many2one('real.project', "Project:"),
            'ft_block':fields.many2one('blocks', string="Block:" ),


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: 8/8/14, 5:43 AM
Seen: 707 times
Last updated: 3/16/15, 8:10 AM