Skip to Content
Menu
This question has been flagged


Please help, I think It's because of the default_get in my hr.employee, I don't know any way to make this work


SAMPLE OUTPUT for EMPLOYEE MODULE when creating:

Academic Experiences

ELEMENTARY





SECONDARY





TERTIARY






In my HR EMPLOYEE i have this default_get() where I will make a default value for a one2many field:

@api.model 
def default_get(self, fields):
result = super(Employee, self).default_get(fields)
acad_ids = []
acad_types = self.env['cfg.academic.type'].search([])
for acad_type in acad_types:
acad = self.env['hr.academic'].create({
'academic_type_id': acad_type.id,
})
acad_ids.append(acad.id)
result['academic_ids'] = acad_ids
return result


## Wherein my def create() I put these in order to assign ID for the newly created employee


@api.model
def create(self, vals):
result = super(Employee, self).create(vals)

if 'academic_ids' in vals:
for rec in vals['academic_ids']:
academic_ids = self.env['hr.academic'].browse(rec[1])
for academic in academic_ids:
academic.write({'employee_id': result.id})
return result

Now, when creating from recruitment which is  create_employee_from_applicant() there is an error when creating new employee but when I comment the default get it creates. 

I would really appreciate your help, thank you in advance.


Avatar
Discard
Related Posts Replies Views Activity
3
Jul 17
10373
6
Aug 19
60733
2
Aug 19
3703
2
Apr 20
3069
1
Nov 17
3212