Skip to content

Commit

Permalink
fix: only make fetch_from field read only if no input (#19192) (#19195)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7578be8)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed Dec 8, 2022
1 parent 19878e2 commit 17e8aa5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frappe/public/js/frappe/form/controls/base_input.js
Expand Up @@ -52,6 +52,14 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control
}
}

read_only_because_of_fetch_from() {
return (
this.df.fetch_from &&
!this.df.fetch_if_empty &&
this.frm?.doc?.[this.df.fetch_from.split(".")[0]]
);
}

// update input value, label, description
// display (show/hide/read-only),
// mandatory style on refresh
Expand Down Expand Up @@ -82,7 +90,7 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control
me.value = me.doc[me.df.fieldname] || "";
}

let is_fetch_from_read_only = me.df.fetch_from && !me.df.fetch_if_empty;
let is_fetch_from_read_only = me.read_only_because_of_fetch_from();

if (me.can_write() && !is_fetch_from_read_only) {
me.disp_area && $(me.disp_area).toggle(false);
Expand Down

0 comments on commit 17e8aa5

Please sign in to comment.