diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js index 661f0fdf19..6a2c263bee 100644 --- a/public/js/legacy/widgets/form/form.js +++ b/public/js/legacy/widgets/form/form.js @@ -53,7 +53,7 @@ _f.Frm = function(doctype, parent, in_form) { this.docname = ''; this.doctype = doctype; this.display = 0; - this.refresh_if_stale_for = 600; + this.refresh_if_stale_for = 120; var me = this; this.last_view_is_edit = {}; @@ -881,16 +881,31 @@ _f.Frm.prototype.reload_doc = function() { var me = this; var onsave = function(r, rtxt) { // n tweets and last comment - me.runclientscript('setup', me.doctype, me.docname); + //me.runclientscript('setup', me.doctype, me.docname); me.refresh(); } if(me.doc.__islocal) { - // reload only doctype - $c('webnotes.widgets.form.load.getdoctype', {'doctype':me.doctype }, onsave, null, null, 'Refreshing ' + me.doctype + '...'); + wn.call({ + method: "webnotes.widgets.form.load.getdoctype", + args: { + doctype: me.doctype + }, + callback: function(r) { + me.refresh(); + } + }) } else { - // reload doc and docytpe - $c('webnotes.widgets.form.load.getdoc', {'name':me.docname, 'doctype':me.doctype, 'getdoctype':1, 'user':user}, onsave, null, null, 'Refreshing ' + me.docname + '...'); + wn.call({ + method: "webnotes.widgets.form.load.getdoc", + args: { + doctype: me.doctype, + name: me.docname + }, + callback: function(r) { + me.refresh(); + } + }); } } diff --git a/webnotes/widgets/form/load.py b/webnotes/widgets/form/load.py index ed564b97cf..e7580f4ed8 100644 --- a/webnotes/widgets/form/load.py +++ b/webnotes/widgets/form/load.py @@ -26,7 +26,7 @@ import webnotes.model.doc import webnotes.utils @webnotes.whitelist() -def getdoc(): +def getdoc(doctype, name, user=None): """ Loads a doclist for a given document. This method is called directly from the client. Requries "doctype", "name" as form variables. @@ -35,18 +35,15 @@ def getdoc(): import webnotes - form = webnotes.form_dict - doctype, docname = form.get('doctype'), form.get('name') - - if not (doctype and docname): + if not (doctype and name): raise Exception, 'doctype and name required!' doclist = [] # single - doclist = load_single_doc(doctype, docname, (form.get('user') or webnotes.session['user'])) + doclist = load_single_doc(doctype, name, user or webnotes.session.user) # load doctype along with the doc - if form.get('getdoctype'): + if webnotes.form_dict.get('getdoctype'): import webnotes.model.doctype doclist += webnotes.model.doctype.get(doctype, processed=True)