Merge branch 'master' of github.com:webnotes/wnframework into edge
This commit is contained in:
commit
320028d7b1
7 changed files with 47 additions and 33 deletions
|
|
@ -46,20 +46,6 @@ class DocType:
|
|||
cnt = 1
|
||||
self.doc.name += '-' + str(cnt)
|
||||
|
||||
def validate(self):
|
||||
"""
|
||||
Update $image tags
|
||||
"""
|
||||
import re
|
||||
p = re.compile('\$image\( (?P<name> [^)]*) \)', re.VERBOSE)
|
||||
if self.doc.content:
|
||||
self.doc.content = p.sub(self.replace_by_img, self.doc.content)
|
||||
|
||||
def replace_by_img(self, match):
|
||||
import webnotes
|
||||
name = match.group('name')
|
||||
return '<img src="cgi-bin/getfile.cgi?ac=%s&name=%s">' % (webnotes.conn.get('Control Panel', None, 'account_id'), name)
|
||||
|
||||
# export
|
||||
def on_update(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ $.extend(wn.model, {
|
|||
if(!in_list(no_value_fields, f.fieldtype) && doc[f.fieldname]==null) {
|
||||
var v = wn.model.get_default_value(f);
|
||||
if(v) {
|
||||
if(in_list(["Int", "Check"], f.fieldtype))
|
||||
v = cint(v);
|
||||
else if(in_list(["Currency", "Float"], f.fieldtype))
|
||||
v = flt(v);
|
||||
|
||||
doc[f.fieldname] = v;
|
||||
updated.push(f.fieldname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ wn.ui.Dialog = wn.ui.FieldGroup.extend({
|
|||
this.appframe.$titlebar.find('.appframe-title').html(t || '');
|
||||
},
|
||||
set_postion: function() {
|
||||
this.zindex = 1;
|
||||
this.zindex = 10;
|
||||
if(cur_dialog) {
|
||||
this.zindex = cur_dialog.zindex + 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,8 +111,17 @@ class Document:
|
|||
def __str__(self):
|
||||
return str(self.fields)
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fields)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.fields)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.fields == other.fields
|
||||
if isinstance(other, Document):
|
||||
return self.fields == other.fields
|
||||
else:
|
||||
return False
|
||||
|
||||
def __getstate__(self):
|
||||
return self.fields
|
||||
|
|
|
|||
|
|
@ -72,7 +72,9 @@ def get_table_fields(doctype):
|
|||
|
||||
return child_tables + custom_child_tables
|
||||
|
||||
def has_field(doctype, fieldname):
|
||||
doclist = webnotes.model.doctype.get(doctype)
|
||||
return doclist.get({"parent":doctype, "doctype":"DocField", "fieldname":fieldname})
|
||||
|
||||
def has_field(doctype, fieldname, parent=None, parentfield=None):
|
||||
return get_field(doctype, fieldname, parent=None, parentfield=None) and True or False
|
||||
|
||||
def get_field(doctype, fieldname, parent=None, parentfield=None):
|
||||
doclist = webnotes.get_doctype(doctype)
|
||||
return doclist.get_field(fieldname, parent, parentfield)
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue