'Overrides mail_thread message_new that is called by the mailgateway
through message_process.
This override updates the document according to the email.'

@api.model
def message_new(self, msg, custom_values=None):

    if (custom_values is None):
        custom_values = {}
    email = ((tools.email_split(msg.get('from')) and tools.email_split(msg.get('from'))[0]) or False)
    user = self.env['res.users'].search([('login', '=', email)], limit=1)
    if user:
        employee = self.env['hr.employee'].search([('user_id', '=', user.id)], limit=1)
        if employee:
            custom_values['employee_id'] = (employee and employee[0].id)
    return super(MaintenanceRequest, self).message_new(msg, custom_values=custom_values)
