diff --git a/frappe/public/js/frappe/form/document_flow.js b/frappe/public/js/frappe/form/document_flow.js index 70cac7b11b..99cca98e10 100644 --- a/frappe/public/js/frappe/form/document_flow.js +++ b/frappe/public/js/frappe/form/document_flow.js @@ -4,12 +4,24 @@ frappe.ui.form.DocumentFlow = Class.extend({ init: function(opts) { $.extend(this, opts); + + this.module = frappe.get_meta(this.frm.doctype).module + if (!frappe.document_flow[this.module]) { + return; + } + this.doctypes = frappe.document_flow[this.module][this.frm.doctype]; + if (!this.doctypes) { + return; + } + this.wrapper = $('').prependTo(this.frm.layout.wrapper); }, refresh: function() { - this.reset(); - this.render(); + if(this.doctypes) { + this.reset(); + this.render(); + } }, reset: function() { @@ -19,18 +31,10 @@ frappe.ui.form.DocumentFlow = Class.extend({ render: function() { var me = this; - var module = frappe.get_meta(this.frm.doctype).module - if (!frappe.document_flow[module]) { - return; - } - var doctypes = frappe.document_flow[module][this.frm.doctype]; - if (!doctypes) { - return; - } $(frappe.render_template('form_document_flow', { frm: this.frm, - doctypes: doctypes, + doctypes: this.doctypes, })).appendTo(this.wrapper.removeClass('hidden')); this.wrapper.on('click', '.document-flow-link', function() {