diff --git a/frappe/core/doctype/comment/comment.py b/frappe/core/doctype/comment/comment.py index 04ecc83b38..01707978c8 100644 --- a/frappe/core/doctype/comment/comment.py +++ b/frappe/core/doctype/comment/comment.py @@ -144,7 +144,7 @@ def update_comments_in_parent(reference_doctype, reference_name, _comments): """Updates `_comments` property in parent Document with given dict. :param _comments: Dict of comments.""" - if not reference_doctype or not reference_name or frappe.db.get_value("DocType", reference_doctype, "issingle"): + if not reference_doctype or not reference_name or frappe.db.get_value("DocType", reference_doctype, "issingle") or frappe.db.get_value("DocType", reference_doctype, "virtual_doctype"): return try: diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index f1667b4fa8..e508d6abc2 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -505,18 +505,18 @@ class BaseDocument(object): not _df.get('fetch_if_empty') or (_df.get('fetch_if_empty') and not self.get(_df.fieldname)) ] + if not frappe.get_meta(doctype).virtual_doctype: + if not fields_to_fetch: + # cache a single value type + values = frappe._dict(name=frappe.db.get_value(doctype, docname, + 'name', cache=True)) + else: + values_to_fetch = ['name'] + [_df.fetch_from.split('.')[-1] + for _df in fields_to_fetch] - if not fields_to_fetch: - # cache a single value type - values = frappe._dict(name=frappe.db.get_value(doctype, docname, - 'name', cache=True)) - else: - values_to_fetch = ['name'] + [_df.fetch_from.split('.')[-1] - for _df in fields_to_fetch] - - # don't cache if fetching other values too - values = frappe.db.get_value(doctype, docname, - values_to_fetch, as_dict=True) + # don't cache if fetching other values too + values = frappe.db.get_value(doctype, docname, + values_to_fetch, as_dict=True) if frappe.get_meta(doctype).issingle: values.name = doctype