fix: only check for valid child table fields to compare doctypes

This commit is contained in:
Gursheen Anand 2026-02-24 09:49:20 +05:30
parent 39b0cea12f
commit 24eec8cf44
3 changed files with 15 additions and 9 deletions

View file

@ -72,10 +72,8 @@ context("Web Form", () => {
cy.call("logout");
cy.visit("/note");
cy.get_open_dialog()
.get(".modal-message")
.contains("You are not permitted to access this page without login.");
cy.visit("/note", { failOnStatusCode: false });
cy.contains("You must be logged in to use this form.");
});
it("Show List", () => {

View file

@ -126,8 +126,8 @@ frappe.ui.form.ControlAttach = class ControlAttach extends frappe.ui.form.Contro
.attr("href", dataurl || this.value);
}
} else {
this.$input.toggle(true);
this.$value.toggle(false);
this.$input?.toggle(true);
this.$value?.toggle(false);
}
}

View file

@ -839,9 +839,17 @@ def has_link_option(fields, doctype):
for f in fields:
if f.options == doctype:
return True
if hasattr(f, "fields") and isinstance(f.fields, list):
if has_link_option(f.fields, doctype):
return True
if f.fieldtype == "Table" and f.options:
child_doctype = f.options
if not isinstance(child_doctype, str) or not child_doctype.strip():
continue
try:
child_table_fields = frappe.get_meta(child_doctype).fields
except Exception:
continue
for child_field in child_table_fields:
if getattr(child_field, "options", None) == doctype:
return True
return False