تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
5050 أدوات العرض

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}
الصورة الرمزية
إهمال
أفضل إجابة

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.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مارس 25
1904
4
أبريل 24
175037
0
ديسمبر 23
2632
5
يوليو 25
230480
1
ديسمبر 22
3783