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

many2one (dropdown) inside one2many (editable tree): Value display issue

By
Narender
on 2/10/15, 10:27 AM 549 views

Hello everyone, can someone please throw some light on the following issue:

I have got a requirement where I need to have a many2one field in a one2many (editable tree). I successfully managed to add the many2one field in the one2many editable tree. However the issue that I have at the moment is the value of the selected item in the drop down (i.e. many2one field) is displaying as hr.x.y, 1 and not the actual value.

KInd Regards

0
Narender
On 2/11/15, 6:12 AM

Issue Solved

That was silly me.

class x_y_z(osv.osv):
    _name = 'x.y.z'
    _description = 'xyz description'
    _columns = {
        'name': fields.char('abcd field name', required=True),

         'pqrs': fields.char('pqrs field name', required=True),
       }

class e_f_g(osv.osv):
    _name = 'e.f.g'
    _description = 'efg description'
    _columns = {

x_y_z: fields.many2one(x.y.z, "xyz many2one")

}

here the field 'name' in x_y_z class is required to display the value properly, which i did not use initially and that was causing poblems

 

Thanks for correcting me ivan

Narender
on 2/11/15, 6:21 AM
0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 2/11/15, 6:19 AM

Responding to @Narender's answer: No, column "name" is not mandatory, although it is helpful.  But, you do have to designate a column with different name to be the "name" column (which, if not specified will default to column "name").  You can specify it in the _rec_name = "x_y_z", for example in the class e_f_g().  Another way to override the behaviour is to override the name_get() method of the class.  Here you can even combine several column's content as the name.  The original behaviour (if "name" column does not exist and is not specified in _rec_name attribute and name_get() is not overridden) is to display model_name,database_id pair.

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

1 follower(s)

Stats

Asked: 2/10/15, 10:27 AM
Seen: 549 times
Last updated: 3/16/15, 8:10 AM