Odoo Help

0

onchange method on Many2one fields ?

By
sunil
on 9/9/13, 8:33 AM 2,270 views

ex. There Are many plan on many2one fields like Plan offender :plan-1 1.A 2.B 3.C :plan-2 1.D 2.E

                     **:plan-3**
                              *1.F*

Select maste plan-1 from many2one fieds and next dropdown list box( ( many2one)) display plan-1 related sub plan show my Code :def onchange_getplan(self, cr, uid, ids, plans_offered, context=None):

    if not plans_offered:
        return {'value': {}}
    name_browse = self.browse(cr, uid, plans_offered , context=context)
    print "name_browse:>>>", name_browse
    plan_obj = self.pool.get('membership.plan.master').browse(cr, uid, name_browse.id, context=context)
    print "\n\n\npersons_connected_with_plan",plan_obj.id
    data = self.pool.get('all.plan.master').search(cr, uid, [('plans','=',plan_obj.id)], context=context)
    print "d a t a :>", data
    for plan_object in data:
        print ">>>>>>>>>>>>>>> plan_object id", plan_object
        a = self.pool.get('all.plan.master').browse(cr, uid, plan_object)
        print "A:>>>>", a, a.plan_name
        new_val.append({'sub_plan': a.id})
    #       plan_object.id = plan_object
    print 'new_val:>>>>',new_val

}

  return {'value': new_val}
0
Andreas Brueckl
On 9/18/13, 12:16 PM

The syntax for the return value of on_change function is the following:

{"value" : 
     {"field1": "value1", "field2": value2}, 
  "domain": {"plan2": [("parent_id", "=", plan1_id)]},
}

If you want to show only certain values in field plan2, you have to return the according domain for the field plan2.

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.

Register

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

0 follower(s)

Stats

Asked: 9/9/13, 8:33 AM
Seen: 2270 times
Last updated: 3/16/15, 8:10 AM