Odoo Help


Onchange name event Attribute Error

Nanda Kanoko
on 7/16/13, 7:46 AM 2,965 views

I'm struggling to make name onchange event to match the project_id

My py :

class notebook_project(osv.osv):
    _name = "notebook.project"
    _description = "Notebook Project ID"
    _columns = {
        'name' : fields.char('Name', size=64),
        'project_id' : fields.many2one('project.project', 'Project'),
        'notebook_project_lines' : fields.one2many('notebook.project', 'notebook_project_id', 'Members Lines'),
        'notebook_project_id': fields.many2one('notebook.project', ondelete='cascade', select=True),
        'project_member' : fields.many2one('hr.employee', 'Members'),


def onchange_project_id(self, cr, uid, ids, project_id, name, context=None):

    if project_id:
        prod = self.pool.get('project.project').browse(cr, uid, project_id, context=context)
        return {'value': {'name': prod.name}}
    return {}



<record model="ir.ui.view" id="notebook_project_tree_view">
<field name="name">notebook.project.tree</field>
<field name="model">notebook.project</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Project">
<field name="name"/> 
<field name="notebook_project_lines"/>

<record model="ir.ui.view" id="notebook_project_form_view">
<field name="name">notebook.project.form</field>
<field name="model">notebook.project</field>
<field name="type">form</field>
<field name="arch" type="xml">

<form string="Notebook Project"> 
<field name="project_id" on_change="project_id(project_id, name, context)"/>
<field name="name"/>

I always get AttributeError: 'notebook_project' object has no attribute 'project_id' , any help appreciated :D

ainur rofiq
On 7/16/13, 1:26 PM

The error message is very clear. Please check again, your method between class definition and xml is not match . It should be <field name="project_id" on_change="onchange_project_id(project_id, name, context)"/>

Thanks for reply , i've tried it but still got an attribute error ...

Nanda Kanoko
on 7/16/13, 11:17 PM

have you re-start openerp server after update your code?

KAM, ainur rofiq
on 7/17/13, 1:35 AM

of course ...

Nanda Kanoko
on 7/17/13, 3:04 AM

kok aneh ya mas bro...

KAM, ainur rofiq
on 7/17/13, 5:07 AM

udah kelar kok bro , ternyata masalah tab function aja kok . Thanks bantuannya :D

Nanda Kanoko
on 7/17/13, 5:09 AM

mas bro tolong dibantu : http://help.openerp.com/question/24804/how-to-import-one2many-field-record-from-one-model-to-one2many-field-in-another-model/

Nanda Kanoko
on 7/17/13, 6:20 AM

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