Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5045 Lượt xem

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}
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 25
1884
4
thg 4 24
175003
0
thg 12 23
2613
5
thg 7 25
230412
1
thg 12 22
3759