diff --git a/frappe/public/js/frappe/form/form.js b/frappe/public/js/frappe/form/form.js index 9fef63f231..c7f70ce3b9 100644 --- a/frappe/public/js/frappe/form/form.js +++ b/frappe/public/js/frappe/form/form.js @@ -428,7 +428,6 @@ frappe.ui.form.Form = class FrappeForm { this.read_only = frappe.workflow.is_read_only(this.doctype, this.docname); if (this.read_only) { this.set_read_only(); - frappe.show_alert(__("This form is not editable due to a Workflow.")); } // check if doctype is already open @@ -448,11 +447,6 @@ frappe.ui.form.Form = class FrappeForm { // load the record for the first time, if not loaded (call 'onload') this.trigger_onload(switched); - // if print format is shown, refresh the format - // if(this.print_preview.wrapper.is(":visible")) { - // this.print_preview.preview(); - // } - if (switched) { if (this.show_print_first && this.doc.docstatus === 1) { // show print view @@ -749,6 +743,7 @@ frappe.ui.form.Form = class FrappeForm { this.show_submit_message(); this.clear_custom_buttons(); this.show_web_link(); + this.show_workflow_read_only_banner(); } // SAVE @@ -1262,8 +1257,6 @@ frappe.ui.form.Form = class FrappeForm { } else if (this.doctype == "DocType") { if (frappe.views.formview[docname] || frappe.pages["List/" + docname]) { window.location.reload(); - // frappe.msgprint(__("Cannot open {0} when its instance is open", ['DocType'])) - // throw 'doctype open conflict' } } else { if ( @@ -1271,8 +1264,6 @@ frappe.ui.form.Form = class FrappeForm { frappe.views.formview.DocType.frm.opendocs[this.doctype] ) { window.location.reload(); - // frappe.msgprint(__("Cannot open instance when its {0} is open", ['DocType'])) - // throw 'doctype open conflict' } } } @@ -2260,6 +2251,26 @@ frappe.ui.form.Form = class FrappeForm { } }); } + + show_workflow_read_only_banner() { + if (!this.read_only) { + return; + } + + const _show_read_only_banner = () => { + this.dashboard.set_headline( + __("This form is not editable due to a Workflow."), + "blue", + true + ); + }; + + if (this.dashboard) { + _show_read_only_banner(); + } else { + frappe.after_ajax(_show_read_only_banner); + } + } }; frappe.validated = 0;