Odoo Help


Many2one field shows only id

on 6/20/13, 7:13 AM 4,399 views

Hello, I am modifying Employee directory app, I am adding new menu items and forms for employee faults. Faults form has many2one field where you can choose fault type. When I am creating fault type everything is ok, it shows name and severity like it should, but when I am trying to choose it in many2one field it only shows module name and id e.g hr.fault,1. I want it to show fault types name. What I am missing? Here is my code:

class hr_faults(osv.osv):
_inherits = {'resource.resource': "e_name"}

_name = "hr.faults"
_description = "Faults"

def get_total(self, cr, uid, ids, context=None):

    address = self.pool.get('hr.fault').browse(cr, uid, ids, context=context)

    return address.s_name

_columns = {
    'e_name':fields.many2one('hr.employee', 'Name'),

    'fault_date': fields.date('Date', transale=True),
    'rec_name': fields.many2one('hr.employee', 'Recorded by'),
    'f_type': fields.many2one('hr.fault','Fault type',select=True,type='char'),
    'f_comment': fields.text('Comment'),
    'f_severity': fields.related('f_type','fs_severity',type='integer', string='Severity',readonly=True,),
    'resource_id':fields.related('e_name','resource_id',type='integer', string='Name', readonly=True, store=True),



class hr_fault(osv.osv):

_name = "hr.fault"
_description = "Faults types"

_columns = {
    's_name':fields.char('Fault type',required=True,select=True,store=True,type='char',   priority=1),
    'fs_severity': fields.selection([('1', '1'),('2', '2'),('3', '3'),('4', '4'),('5', '5')], 'Severity',store=True),


Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 6/20/13, 9:04 AM

just change the fields' name: change "s_name" to "name" and "e_name" to "name"

_columns : {
           'name': fields.char(....

Thanks a lot mate, now it's working properly

on 6/20/13, 9:48 AM
On 9/13/13, 5:31 AM

add : _rec_name="Your Fields"


Atul Kumar jain

--Atul Kumar jain--
Atul Kumar jain
| 5 3 7
Indore, India
--Atul Kumar jain--


Atul Kumar jain
On 3/13/14, 6:29 AM

you can add this line after description so it will work for your existing field



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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 6/20/13, 7:13 AM
Seen: 4399 times
Last updated: 3/16/15, 8:10 AM