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

Onchange name inside o2m field

By
Nanda Kanoko
on 7/30/13, 3:37 AM 699 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)

        }


notebook_project()

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

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: 7/30/13, 3:37 AM
Seen: 699 times
Last updated: 3/16/15, 8:10 AM