@@ -8,9 +8,6 @@ body { | |||||
padding: 0px; | padding: 0px; | ||||
font-size: 14px; | font-size: 14px; | ||||
color: #000; | color: #000; | ||||
} | |||||
body { | |||||
background-color: #eee; | background-color: #eee; | ||||
} | } | ||||
@@ -50,6 +50,7 @@ | |||||
background-color: #eee; | background-color: #eee; | ||||
padding: 2px; | padding: 2px; | ||||
border: 1px solid #ddd; | border: 1px solid #ddd; | ||||
margin-bottom: 7px; | |||||
-webkit-border-radius: 3px; | -webkit-border-radius: 3px; | ||||
-moz-border-radius: 3px; | -moz-border-radius: 3px; | ||||
@@ -104,10 +104,11 @@ _f.FrmHeader = Class.extend({ | |||||
this.set_label(labinfo); | this.set_label(labinfo); | ||||
// show update button if unsaved | // show update button if unsaved | ||||
if(cur_frm.doc.__unsaved && cint(cur_frm.doc.docstatus)==1 && this.appframe.buttons['Update']) { | |||||
this.appframe.buttons['Update'].toggle(true); | |||||
if(cur_frm.doc.__unsaved && cint(cur_frm.doc.docstatus)==1 && cur_frm.perm[0][SUBMIT]) { | |||||
this.appframe.add_button('Update', function() { | |||||
cur_frm.save('Update', null, this); | |||||
}, '') | |||||
} | } | ||||
}, | }, | ||||
set_label: function(labinfo) { | set_label: function(labinfo) { | ||||
this.$w.find('.label').remove(); | this.$w.find('.label').remove(); | ||||
@@ -148,34 +149,23 @@ _f.FrmHeader = Class.extend({ | |||||
this.appframe.buttons['Save'].addClass('btn-info') | this.appframe.buttons['Save'].addClass('btn-info') | ||||
.html("<i class='icon-save'></i> Save (Ctrl+S)"); | .html("<i class='icon-save'></i> Save (Ctrl+S)"); | ||||
} | } | ||||
// Submit | |||||
if(docstatus==0 && p[SUBMIT] && (!cur_frm.doc.__islocal)) | |||||
this.appframe.add_button('Submit', function() { | |||||
cur_frm.savesubmit(this);}, 'icon-lock'); | |||||
// Update after sumit | |||||
if(docstatus==1 && p[SUBMIT]) { | |||||
this.appframe.add_button('Update', function() { | |||||
cur_frm.save('Update', null, this); | |||||
}, '').toggle(false); | |||||
} | |||||
// Cancel | |||||
if(docstatus==1 && p[CANCEL]) | |||||
this.appframe.add_button('Cancel', function() { | |||||
cur_frm.savecancel(this) }, 'icon-remove'); | |||||
// Submit | |||||
if(!wn.model.get("Workflow", {document_type: cur_frm.doctype}).length) { | |||||
if(docstatus==0 && p[SUBMIT] && (!cur_frm.doc.__islocal)) | |||||
this.appframe.add_button('Submit', function() { | |||||
cur_frm.savesubmit(this);}, 'icon-lock'); | |||||
// Amend | |||||
if(docstatus==2 && p[AMEND]) | |||||
this.appframe.add_button('Amend', function() { | |||||
cur_frm.amend_doc() }, 'icon-pencil'); | |||||
// Help | |||||
// if(cur_frm.meta.description) { | |||||
// this.appframe.add_help_button(wn.markdown('#### ' + cur_frm.doctype + '\n\n' | |||||
// + cur_frm.meta.description)); | |||||
// } | |||||
// Cancel | |||||
if(docstatus==1 && p[CANCEL]) | |||||
this.appframe.add_button('Cancel', function() { | |||||
cur_frm.savecancel(this) }, 'icon-remove'); | |||||
// Amend | |||||
if(docstatus==2 && p[AMEND]) | |||||
this.appframe.add_button('Amend', function() { | |||||
cur_frm.amend_doc() }, 'icon-pencil'); | |||||
} | |||||
}, | }, | ||||
show: function() { | show: function() { | ||||
}, | }, | ||||
@@ -64,7 +64,7 @@ wn.form.formatters = { | |||||
return wn.form.formatters.Text(value); | return wn.form.formatters.Text(value); | ||||
}, | }, | ||||
WorkflowState: function(value) { | WorkflowState: function(value) { | ||||
workflow_state = wn.meta.get("Workflow State", value)[0]; | |||||
workflow_state = wn.model.get("Workflow State", value)[0]; | |||||
if(workflow_state) { | if(workflow_state) { | ||||
return repl("<span class='label label-%(style)s' \ | return repl("<span class='label label-%(style)s' \ | ||||
data-workflow-state='%(value)s'\ | data-workflow-state='%(value)s'\ | ||||
@@ -69,7 +69,7 @@ wn.ui.form.States = Class.extend({ | |||||
// set the style | // set the style | ||||
this.$wrapper.find(".btn").removeClass() | this.$wrapper.find(".btn").removeClass() | ||||
.addClass("btn btn-small dropdown-toggle") | |||||
.addClass("btn dropdown-toggle") | |||||
.addClass("btn-" + state_doc.style.toLowerCase()); | .addClass("btn-" + state_doc.style.toLowerCase()); | ||||
// show actions from that state | // show actions from that state | ||||
@@ -92,9 +92,9 @@ $.extend(wn.perm, { | |||||
var out =false; | var out =false; | ||||
if(p.match) { | if(p.match) { | ||||
if(p.match.indexOf(":")!=-1) { | if(p.match.indexOf(":")!=-1) { | ||||
keys = p.match.split(":"); | |||||
var document_key = keys[0]; | |||||
var default_key = keys[1]; | |||||
key_list = p.match.split(":"); | |||||
var document_key = key_list[0]; | |||||
var default_key = key_list[1]; | |||||
} else { | } else { | ||||
var document_key = p.match; | var document_key = p.match; | ||||
var default_key = p.match; | var default_key = p.match; | ||||
@@ -73,7 +73,7 @@ $.extend(wn.model, { | |||||
}, | }, | ||||
compress: function(doclist) { | compress: function(doclist) { | ||||
var keys = {}; var values = []; | |||||
var all_keys = {}; var values = []; | |||||
function get_key_list(doctype) { | function get_key_list(doctype) { | ||||
// valid standard keys | // valid standard keys | ||||
@@ -96,13 +96,13 @@ $.extend(wn.model, { | |||||
var doc = doclist[i]; | var doc = doclist[i]; | ||||
// make keys | // make keys | ||||
if(!keys[doc.doctype]) { | |||||
keys[doc.doctype] = get_key_list(doc.doctype); | |||||
if(!all_keys[doc.doctype]) { | |||||
all_keys[doc.doctype] = get_key_list(doc.doctype); | |||||
// doctype must be first | // doctype must be first | ||||
} | } | ||||
var row = [] | var row = [] | ||||
var key_list = keys[doc.doctype]; | |||||
var key_list = all_keys[doc.doctype]; | |||||
// make data rows | // make data rows | ||||
for(var j=0;j<key_list.length;j++) { | for(var j=0;j<key_list.length;j++) { | ||||
@@ -112,7 +112,7 @@ $.extend(wn.model, { | |||||
values.push(row); | values.push(row); | ||||
} | } | ||||
return JSON.stringify({'_vl':values, '_kl':keys}); | |||||
return JSON.stringify({'_vl':values, '_kl':all_keys}); | |||||
} | } | ||||
}); | }); | ||||
@@ -260,6 +260,8 @@ def get_roles(user=None, with_standard=True): | |||||
def has_permission(doctype, ptype="read"): | def has_permission(doctype, ptype="read"): | ||||
"""check if user has permission""" | """check if user has permission""" | ||||
if session.user=="Administrator": | |||||
return True | |||||
if conn.get_value("DocType", doctype, "istable"): | if conn.get_value("DocType", doctype, "istable"): | ||||
return True | return True | ||||
return conn.sql("""select name from tabDocPerm p | return conn.sql("""select name from tabDocPerm p | ||||
@@ -252,36 +252,36 @@ class ModelWrapper: | |||||
% (dt[0], '%s', '%s'), (self.doc.name, self.doc.doctype)) | % (dt[0], '%s', '%s'), (self.doc.name, self.doc.doctype)) | ||||
def save(self, check_links=1): | def save(self, check_links=1): | ||||
""" | |||||
Save the list | |||||
""" | |||||
self.prepare_for_save(check_links) | |||||
self.run_method('validate') | |||||
self.save_main() | |||||
self.save_children() | |||||
self.run_method('on_update') | |||||
if webnotes.has_permission(self.doc.doctype, "write"): | |||||
self.prepare_for_save(check_links) | |||||
self.run_method('validate') | |||||
self.save_main() | |||||
self.save_children() | |||||
self.run_method('on_update') | |||||
else: | |||||
webnotes.msgprint("No Permission to Write", raise_exception=True) | |||||
def submit(self): | def submit(self): | ||||
""" | |||||
Save & Submit - set docstatus = 1, run "on_submit" | |||||
""" | |||||
if self.doc.docstatus != 0: | |||||
webnotes.msgprint("Only draft can be submitted", raise_exception=1) | |||||
self.to_docstatus = 1 | |||||
self.save() | |||||
self.run_method('on_submit') | |||||
if webnotes.has_permission(self.doc.doctype, "submit"): | |||||
if self.doc.docstatus != 0: | |||||
webnotes.msgprint("Only draft can be submitted", raise_exception=1) | |||||
self.to_docstatus = 1 | |||||
self.save() | |||||
self.run_method('on_submit') | |||||
else: | |||||
webnotes.msgprint("No Permission to Submit", raise_exception=True) | |||||
def cancel(self): | def cancel(self): | ||||
""" | |||||
Cancel - set docstatus 2, run "on_cancel" | |||||
""" | |||||
if self.doc.docstatus != 1: | |||||
webnotes.msgprint("Only submitted can be cancelled", raise_exception=1) | |||||
self.to_docstatus = 2 | |||||
self.prepare_for_save(1) | |||||
self.save_main() | |||||
self.save_children() | |||||
self.run_method('on_cancel') | |||||
if webnotes.has_permission(self.doc.doctype, "submit"): | |||||
if self.doc.docstatus != 1: | |||||
webnotes.msgprint("Only submitted can be cancelled", raise_exception=1) | |||||
self.to_docstatus = 2 | |||||
self.prepare_for_save(1) | |||||
self.save_main() | |||||
self.save_children() | |||||
self.run_method('on_cancel') | |||||
else: | |||||
webnotes.msgprint("No Permission to Cancel", raise_exception=True) | |||||
def update_after_submit(self): | def update_after_submit(self): | ||||
""" | """ | ||||