fix: check if field is a default field before getting df (#9953)

This commit is contained in:
Prssanna Desai 2020-04-15 19:34:12 +05:30 committed by GitHub
parent 4fb9717074
commit a5daf8ffa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -506,9 +506,13 @@ class BaseDocument(object):
fetch_from_fieldname = _df.fetch_from.split('.')[-1]
value = values[fetch_from_fieldname]
if _df.fieldtype == 'Small Text' or _df.fieldtype == 'Text' or _df.fieldtype == 'Data':
fetch_from_df = frappe.get_meta(doctype).get_field(fetch_from_fieldname)
fetch_from_ft = fetch_from_df.get('fieldtype')
if fetch_from_fieldname in default_fields:
from frappe.model.meta import get_default_df
fetch_from_df = get_default_df(fetch_from_fieldname)
else:
fetch_from_df = frappe.get_meta(doctype).get_field(fetch_from_fieldname)
fetch_from_ft = fetch_from_df.get('fieldtype')
if fetch_from_ft == 'Text Editor' and value:
value = unescape_html(strip_html(value))
setattr(self, _df.fieldname, value)