Merge pull request #12786 from surajshetty3416/fix-virtual-doctype

fix: Check if doctype is virtual doctype before getting value
This commit is contained in:
Suraj Shetty 2021-04-02 19:35:59 +05:30 committed by GitHub
commit 1767d87dfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -455,9 +455,9 @@ class Database(object):
elif (not ignore) and frappe.db.is_table_missing(e):
# table not found, look in singles
out = self.get_values_from_single(fields, filters, doctype, as_dict, debug, update)
if not out:
if not out and frappe.get_meta(doctype).get('is_virtual'):
# check for virtual doctype
out = self.get_values_from_virtual_doctype(fields, filters, doctype, as_dict, debug, update)
out = self.get_value_from_virtual_doctype(fields, filters, doctype, as_dict, debug, update)
else:
raise
@ -511,9 +511,9 @@ class Database(object):
else:
return r and [[i[1] for i in r]] or []
def get_values_from_virtual_doctype(self, fields, filters, doctype, as_dict=False, debug=False, update=None):
"""Reture single values from virtual doctype."""
return frappe.get_doc(doctype).get_value(fields, filters, as_dict=False, debug=False, update=None)
def get_value_from_virtual_doctype(self, fields, filters, doctype, as_dict=False, debug=False, update=None):
"""Return a single value from virtual doctype."""
return frappe.get_doc(doctype).get_value(fields, filters, as_dict=as_dict, debug=debug, update=update)
def get_singles_dict(self, doctype, debug = False):
"""Get Single DocType as dict.