Hi,
What you can do for this is that, just override the create method the model hr.employee and assign the related user to the employee.
class HrEmployee(models.Model):
_inherit = 'hr.employee'
@api.model
def create(self, vals):
# In the vals you will have the work email and all other details
# compare the email with the mail of users
user_rec = self.env['res.users'].search([('login', '=', vals['work_email'])], limit=1)
vals['user_id'] = user_rec.id
res = super(HrEmployee, self).create(vals)
return res
Just print the vals and see how to access the work email and user_id. vals['work_email'] and vals['user_id'], may not be the way to access it, just check and adjust accordingly
Thanks