我有另一个问题,请再帮我一次。 我有四个名为“部门,部门,科”的班级,如吼叫
系
class dept_new_registration(osv.osv):
_name = "hr.dept.n.registration"
_description = "depts"
_columns = {
'name': fields.char('Dept Name', size=128, required=True),
'company_id': fields.many2one('res.company', 'Company Name', required=True),
'divisions': fields.one2many('hr.division.n.registration', 'dept_id', 'Division'),
'resres':fields.one2many('res.users','alias_id')
# 'deptdept':field.integer('For Dept Ref'),
}
dept_new_registration()
司
class division_new_registration(osv.osv):
_name = "hr.division.n.registration"
_description = "Divisions"
_columns = {
'name': fields.char('Division Name', size=128, ),
'dept_id': fields.many2one('hr.dept.n.registration', 'Dept. Name', select=True, required=True),
'sections': fields.one2many('hr.section.n.registration', 'section_id', 'Section'),
# 'dividivi':fields.integer('For Division Ref'),
}
division_new_registration()
科
class section_new_registration(osv.osv):
def create(self, cr, uid, values, context=None):
vals = {}
divi_id = self.pool.get('hr.division.n.registration').browse(cr,uid, values['section_id']).id
divi_name = self.pool.get('hr.division.n.registration').browse(cr,uid, divi_id).name
dept_id = self.pool.get('hr.division.n.registration').browse(cr,uid, values['section_id']).dept_id.id
dept_name = self.pool.get('hr.dept.n.registration').browse(cr,uid, dept_id).name
name = str(dept_name) + '/' +str(divi_name) + '/' + str(values['section_name'])
values.update({'name': name})
return super(section_new_registration, self).create(cr, uid, values, context=context)
_name = "hr.section.n.registration"
_description = "sections"
_columns = {
'name': fields.char('Name', size=128),
'complete_name':fields.char('New Loacation'),
'section_name': fields.char('Section Name', size=128, required=True),
'section_id': fields.many2one('hr.division.n.registration', 'Division Name', select=True, required=True),
'test_id':fields.integer('Test'),
}
section_new_registration()
我已在 hr_department 表中成功链接了所有这四个,并存储了用于创建公司结构的值。 在 hr_department ,
_columns = {
'name': fields.char('Segment Name', size=64, required=True, ),
'complete_name': fields.char('Complete Name'),
'parent_id': fields.many2one('hr.department', 'Parent Segment', select=True),
'child_ids': fields.one2many('hr.department', 'parent_id', 'Child Departments'),
'note': fields.text('Employment Remarks'),
'company_id': fields.many2one('res.company', 'Company', select=True, required=False),
'section_id':fields.many2one('hr.section.n.registration','Section'),
'devision_id':fields.related('section_id','section_id', type="many2one", relation='hr.division.n.registration',string='Devision', store=True),
'depart_id':fields.related('devision_id', 'dept_id', type="many2one", relation='hr.dept.n.registration',string='Department', store=True),
}
我需要的是,我需要按原样调用 hr_employee 表中的所有这四列,当我像下面那样调用它时,它每次都会抛出一个keyError。请在这件事上给予我帮助, 在 hr_employee
中'sec_id': fields.related('department_id', 'section_id', type="many2one", relation='hr.department',string='Section',store=True),
'division_id':fields.related('department_id','devision_id', type="many2one", relation='hr.department', string='Division', store=True),
'departmnt_id':fields.related('department_id', 'depart_id', type="many2one", relation='hr.department',string='Department', store=True),
'comp_id': fields.related('department_id', 'company_id', type="many2one", relation='hr.department',string='Company',store=True),
请帮助我,并提前非常感谢