'Returns document of `reference_doctype`, `reference_doctype`'

def get_parent_doc(self):

    if (not hasattr(self, u'parent_doc')):
        if (self.reference_doctype and self.reference_name):
            self.parent_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
        else:
            self.parent_doc = None
    return self.parent_doc
