Odoo Help


Onchange name inside o2m field

Nanda Kanoko
on 7/30/13, 3:37 AM 1,150 views

I want to set name inside o2m field using onchange event

My code :

class notebook_project(osv.osv):
    _name = "notebook.project"
    _description = "Notebook Project ID"

def onchange_project(self, cr, uid, ids, project, arg, context=None):
    if project :
        proj = self.pool.get('project.project').browse(cr, uid, project, context=context)
        return {'value': {
                'name': proj.name
                'project_name' : proj.name
    return {}

    def onchange_member(self, cr, uid, ids, member, member_name, context=None):
        if member :
            proj = self.pool.get('hr.employee').browse(cr, uid, member, context=context)
            return {'value': {'member_name': proj.name}}
        return {}

    _columns = {
        'name' : fields.char('Project Name', size=64),
        'project' : fields.many2one('project.project', 'Project'),
        'project_lines' : fields.one2many('notebook.project', 'project_id', 'Members Lines'),
        'project_id': fields.many2one('notebook.project', 'Parent Project', ondelete='cascade', select=True),
        'member' : fields.many2one('hr.employee', 'Members'),
        'member_name' : fields.char('Employee Name', size=64),
        'project_name' : fields.char('Project Name', size=64),


    #_defaults = {
        'project_name' : lambda x, cr, uid, c: x.pool.get('notebook.project').browse(cr, uid, project, context=context)



Tried using onchange but no success , the same with using _default . Please help :)

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

1 follower(s)


Asked: 7/30/13, 3:37 AM
Seen: 1150 times
Last updated: 3/16/15, 8:10 AM