Odoo Help

Welcome!

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.

0

Dymnamic many2one on onchnage

By
Praveen Upadhyaya
on 8/8/14, 5:43 AM 382 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:" ),

 

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)

Stats

Asked: 8/8/14, 5:43 AM
Seen: 382 times
Last updated: 3/16/15, 8:10 AM