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

i want remove repetition from my select box .my code is def _sel_func(self, cr, uid,context=None): cr.execute("select distinct on(caller) id,caller FROM calldata1 order by caller") result = cr.fetchall() lst = [] for r in result: dct = {} dct['id'] = r[o] dct['name'] = r[1] lst.append(dct) res_ids = [(r['id'], r['name']) for r in lst] return res_ids

_columns = { 'date_start': fields.date('Date Start', required=True), 'date_end': fields.date('Date End', required=True), 'caller_id':fields.many2one( 'calldata1', 'Caller', selection=_sel_func, ) } but it shows all the data in select box and shows error " ValidateError

The value "7172" for the field "calldata_print_report_wiz.caller_id" is not in the selection " when selecting this and clicking print. How to show only the data from query in select box .Any one please help?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Try to add a field 'name' to the object you display through many2one

Ảnh đại diện
Huỷ bỏ
Tác giả

adding name field corrected the issue

Tác giả

How can io get distict value for this name filed?

Tác giả

i want remove repetition from my select box .my code is def _sel_func(self, cr, uid,context=None): cr.execute("select distinct on(caller) id,caller FROM calldata1 order by caller") result = cr.fetchall() lst = [] for r in result: dct = {} dct['id'] = r[o] dct['name'] = r[1] lst.append(dct) res_ids = [(r['id'], r['name']) for r in lst] return res_ids

_columns = { 'date_start': fields.date('Date Start', required=True), 'date_end': fields.date('Date End', required=True), 'caller_id':fields.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 20
3243
1
thg 8 17
3695
0
thg 3 15
3055
1
thg 9 23
1707
1
thg 7 19
6774