onchange イベントを使用して o2m フィールド内に名前を設定したい
私のコード:
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()
onchange を使用してみましたが、 _default を使用した場合と同じように成功しませんでした。助けてください :)