revert: fetch validations (#25343)

This commit is contained in:
Ankush Menat 2024-03-11 20:29:18 +05:30 committed by GitHub
parent 8bbb69a883
commit fc7366deef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1596,49 +1596,6 @@ def validate_fields(meta: Meta):
if docfield.options and (int(docfield.options) > 10 or int(docfield.options) < 3):
frappe.throw(_("Options for Rating field can range from 3 to 10"))
def check_fetch_from(docfield):
if not frappe.request and not in_ci:
return
fetch_from = docfield.fetch_from
fieldname = docfield.fieldname
if not fetch_from:
return
if "." not in fetch_from:
frappe.throw(
_("Fetch From syntax for field {0} is invalid. `.` dot missing: {1}").format(
frappe.bold(fieldname), frappe.bold(fetch_from)
)
)
link_fieldname, source_fieldname = docfield.fetch_from.split(".", 1)
if not link_fieldname or not source_fieldname:
frappe.throw(
_(
"Fetch From syntax for field {0} is invalid: {1}. Fetch From should be in form of 'link_fieldname.source_fieldname'"
).format(frappe.bold(fieldname), frappe.bold(fetch_from))
)
link_df = meta.get("fields", {"fieldname": link_fieldname, "fieldtype": "Link"})
if not link_df:
frappe.throw(
_("Fetch From for field {0} is invalid: {1}. Link field {2} not found.").format(
frappe.bold(fieldname), frappe.bold(fetch_from), frappe.bold(link_fieldname)
)
)
doctype = link_df[0].options
fetch_from_doctype = frappe.get_meta(doctype)
if not frappe.db.has_column(doctype, source_fieldname) and not fetch_from_doctype.get_field(
source_fieldname
):
frappe.throw(
_("Fetch From for field {0} is invalid: {1} does not have a field {2}").format(
frappe.bold(fieldname), frappe.bold(doctype), frappe.bold(source_fieldname)
)
)
fields = meta.get("fields")
fieldname_list = [d.fieldname for d in fields]
@ -1676,7 +1633,6 @@ def validate_fields(meta: Meta):
check_child_table_option(d)
check_max_height(d)
check_no_of_ratings(d)
check_fetch_from(d)
if not frappe.flags.in_migrate or in_ci:
check_fold(fields)