Skip to content

Commit

Permalink
fix: only make fetch_from field read only if no input (backport #19192)…
Browse files Browse the repository at this point in the history
… (#19194)

* fix: only make fetch_from field read only if no input (#19192)

(cherry picked from commit 7578be8)

* chore: v13 js compatibility

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed Dec 9, 2022
1 parent 3b18e7e commit 994c1ed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion frappe/public/js/frappe/form/controls/base_input.js
Expand Up @@ -50,6 +50,16 @@ frappe.ui.form.ControlInput = frappe.ui.form.Control.extend({
}
},

read_only_because_of_fetch_from() {
return (
this.df.fetch_from &&
!this.df.fetch_if_empty &&
this.frm &&
this.frm.doc &&
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 @@ -80,7 +90,7 @@ frappe.ui.form.ControlInput = frappe.ui.form.Control.extend({
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 994c1ed

Please sign in to comment.