ProgrammingError:无法在odoo10中调整类型'hr.employee'

时间:2017-07-13 01:49:46

标签: python-2.7 odoo-10

当hr_employee创建时,我想hr_contrac创建代码是打击,请你能帮助我。谢谢。

def create(self, vals):
    print vals,"AAAAAAAAAAAA"
    unique_id = self.env['ir.sequence'].get('hr.employee')
    print unique_id,"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBb"
    vals['unique_id'] = unique_id     
    vals['unique_id_integer'] = int(unique_id)

    name = "Contract"+":"+vals['unique_id']+":"+vals['name']
    tools.image_resize_images(vals)
    #return super(Employee, self).create(vals)  
    hr_employee_id = super(Employee, self).create(vals)
    print hr_employee_id 
    if 'date_joined' in vals:
        date_joined = vals['date_joined']
        name += ":"+date_indian(vals['date_joined'])
    if 'job_id' in vals:
        job_id = vals['job_id']
        name += ":"+self.env['hr.job'].browse(vals['job_id']).name        
    contract_data = {
                 'name': name,
                 'job_id': job_id,
                 'employee_id': hr_employee_id,
                 'type_id': 1,
                 'struct_id': 1,
                 'date_start': date_joined,
                 'wage': 0.0,
                 'schedule_pay':'monthly'
                    }

    #self.env['hr.contract'].create(contract_data)
    print contract_data,"AAAAAAAAAAAAAA"
    if contract_data:
        self.env["hr.contract"].create(contract_data)


    return True

此代码无效

self.env["hr.contract"].create(contract_data)

它引发错误:无法调整类型'hr.employee'

1 个答案:

答案 0 :(得分:0)

使用hr_employee_id.id代替hr_employee_id 试试这个:

contract_data = {
             'name': name,
             'job_id': job_id,
             'employee_id': hr_employee_id.id,
             'type_id': 1,
             'struct_id': 1,
             'date_start': date_joined,
             'wage': 0.0,
             'schedule_pay':'monthly'
                }