'Add a comment to this document.
:param comment_type: e.g. `Comment`. See Communication for more info.'

def add_comment(self, comment_type, text=None, comment_by=None, link_doctype=None, link_name=None):

    if (comment_type == u'Comment'):
        out = frappe.get_doc({u'doctype': u'Communication', u'communication_type': u'Comment', u'sender': (comment_by or frappe.session.user), u'comment_type': comment_type, u'reference_doctype': self.doctype, u'reference_name': self.name, u'content': (text or comment_type), u'link_doctype': link_doctype, u'link_name': link_name}).insert(ignore_permissions=True)
    else:
        out = frappe.get_doc(dict(doctype=u'Version', ref_doctype=self.doctype, docname=self.name, data=frappe.as_json(dict(comment_type=comment_type, comment=text))))
        if comment_by:
            out.owner = comment_by
        out.insert(ignore_permissions=True)
    return out
