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

many to one filed shows object only

By
Anuradha
on 8/21/13, 7:39 AM 1,081 views

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?

Prakash
on 8/21/13, 11:01 AM
0
Antanas
On 8/21/13, 11:00 AM

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

adding name field corrected the issue

Anuradha
on 8/27/13, 3:43 AM

How can io get distict value for this name filed?

Anuradha
on 8/28/13, 7:48 AM

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.

Anuradha
on 8/29/13, 7:01 AM

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: 8/21/13, 7:39 AM
Seen: 1081 times
Last updated: 3/16/15, 8:10 AM