0

我想使用 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 相同。请帮忙 :)

4

1 回答 1

0

检查“accout.voucher”对象中 partner_id 的 on_change 事件。

于 2013-08-19T17:46:27.580 回答