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

get Id in field selection

By
lam a bao
on 11/27/13, 5:04 AM 1,373 views

I have field selection ,I want to get Id of the selection,Then I save id on field.char .What should I do

Can you help me ?

selection field or one2many field?

Ayyappan
on 11/27/13, 5:37 AM

i'm sorry . selection is one2many field

lam a bao
on 11/27/13, 5:48 AM
0
Ayyappan
On 11/27/13, 6:05 AM

See the below example

In Python:

  _columns = {
            'name': fields.many2one('hr.employee', "Employee", required=True),
            'id_no': fields.char('Wage', size=64),
        }

        def onchange_employee_id(self, cr, uid, ids, employee_id, context=None):
            v = {}
            if employee_id:
                emp_sr = self.pool.get('hr.employee').search(cr, uid, [('id','=',employee_id)], context=context)
                if emp_sr:
                    empt_br = self.pool.get('hr.employee').browse(cr, uid, emp_sr, context=context)[0]
                    v['id_no'] = str(emp_br.id)

            return {'value': v}

In XML:

<field name="name" on_change="onchange_employee_id(name)"/>
<field name="id_no"/>

No,I have selection ,it is many2one .And i have fields char . when form is loaded ,fields char will get id of selection

lam a bao
on 11/27/13, 10:29 PM

How you select the value to many2one field while form loading? Do you pass any default value to many2one while form loading?

Ayyappan
on 11/28/13, 12:35 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: 11/27/13, 5:04 AM
Seen: 1373 times
Last updated: 3/16/15, 8:10 AM