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

onchange method on Many2one fields ?

By
sunil
on 9/9/13, 8:33 AM 1,794 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

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
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.

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

0 follower(s)

Stats

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