Hi ! First sorry for my poor English !
Here's my problem : I'm
trying to create data in a controller like this. It works and my
employees are created in the employees module.
@http.route('/employees/api/employee', type='json', auth='user', methods=['POST'], cors='*', csrf=False)
def create_employee (self, **kwargs):
data = json.loads(request.httprequest.data)
employee = request.env['hr.employee'].sudo().search([('work_email', '=', data.get('work_email'))])
if employee:
return {'message': 'already exists'}
else:
id = request.env['hr.employee'].sudo().create({
'name': data.get('name'),
'work_email': data.get('email'),
}).id
return {'message': 'Employee {} created'.format(id)}
Now, I want to insert personnal address for this employee, but I don't know how to do that ... In the model, I see that it's in the address_home_id field, but I don't know how to create the address and attach the address_home_id to the newly created address !
Thanks you very much !
PS : I'm on odoo 12 ;)
Controllers in odoo: https://goo.gl/gPjPas