refactor report view to make it thread safe
refactor doctype to make it thread safe
refactor for webnotes.conn.sql