我想使用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相同。请帮助:)
答案 0 :(得分:0)
检查'accout.voucher'对象中的partner_id的on_change事件。