diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js index 79c15bf1ae6..18b58948bc3 100644 --- a/erpnext/accounts/doctype/account/account.js +++ b/erpnext/accounts/doctype/account/account.js @@ -20,33 +20,39 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { } +cur_frm.cscript.set_breadcrumbs = function(barea) { + cur_frm.frm_head.appframe.add_breadcrumb(cur_frm.docname); + cur_frm.frm_head.appframe.add_breadcrumb(' in \ + Chart of Accounts'); + cur_frm.frm_head.appframe.add_breadcrumb(' in Accounts'); +} + // Refresh // ----------------------------------------- cur_frm.cscript.refresh = function(doc, cdt, cdn) { - // read-only for root accounts - root_acc = ['Application of Funds (Assets)','Expenses','Income','Source of Funds (Liabilities)']; - if(inList(root_acc, doc.account_name)) - cur_frm.perm = [[1,0,0], [1,0,0]]; - // hide fields if group cur_frm.toggle_fields(['account_type', 'master_type', 'master_name', 'freeze_account', - 'credit_days', 'credit_limit'], doc.group_or_ledger=='Ledger') + 'credit_days', 'credit_limit', 'tax_rate'], doc.group_or_ledger=='Ledger') - // credit days and type if customer or supplier - cur_frm.toggle_fields(['credit_days', 'credit_limit'], - in_list(['Customer', 'Supplier'], doc.master_type)) + cur_frm.toggle_fields('account_name', doc.__islocal) - // hide tax_rate - cur_frm.cscript.account_type(doc, cdt, cdn); + // read-only for root accounts + root_acc = ['Application of Funds (Assets)','Expenses','Income','Source of Funds (Liabilities)']; + if(in_list(root_acc, doc.account_name)) { + cur_frm.perm = [[1,0,0], [1,0,0]]; + cur_frm.set_intro("This is a root account and cannot be edited."); + } else { + // credit days and type if customer or supplier + cur_frm.set_intro(null); + cur_frm.toggle_fields(['credit_days', 'credit_limit'], + in_list(['Customer', 'Supplier'], doc.master_type)) - // show / hide convert buttons - cur_frm.cscript.hide_unhide_group_ledger(doc); - - // back to chart of accounts - cur_frm.add_custom_button('Back To Chart of Accounts', function() { - wn.set_route('Accounts Browser', 'Account'); - }, 'icon-arrow-left') - + // hide tax_rate + cur_frm.cscript.account_type(doc, cdt, cdn); + + // show / hide convert buttons + cur_frm.cscript.hide_unhide_group_ledger(doc); + } } // Fetch parent details @@ -57,8 +63,12 @@ cur_frm.add_fetch('parent_account', 'is_pl_account', 'is_pl_account'); // Hide tax rate based on account type // ----------------------------------------- cur_frm.cscript.account_type = function(doc, cdt, cdn) { - cur_frm.toggle_fields(['tax_rate'], doc.account_type == 'Tax') - cur_frm.toggle_fields(['master_type', 'master_name'], cstr(doc.account_type)=='') + if(doc.group_or_ledger=='Ledger') { + cur_frm.toggle_fields(['tax_rate'], + doc.account_type == 'Tax'); + cur_frm.toggle_fields(['master_type', 'master_name'], + cstr(doc.account_type)==''); + } } // Hide/unhide group or ledger diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index f721e42f2d7..9b6670454ca 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -26,17 +26,25 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { } +cur_frm.cscript.set_breadcrumbs = function(barea) { + cur_frm.frm_head.appframe.add_breadcrumb(cur_frm.docname); + cur_frm.frm_head.appframe.add_breadcrumb(' in \ + Chart of Cost Centers'); + cur_frm.frm_head.appframe.add_breadcrumb(' in Accounts'); +} + cur_frm.cscript.refresh = function(doc, cdt, cdn) { - cur_frm.cscript.hide_unhide_group_ledger(doc); - cur_frm.add_custom_button('Back To Chart of Cost Centers', function() { - wn.set_route('Accounts Browser', 'Cost Center'); - }, 'icon-arrow-left') + cur_frm.toggle_fields('cost_center_name', doc.__islocal) var intro_txt = ''; if(!doc.__islocal && doc.group_or_ledger=='Group') { intro_txt += '
Note: This is Cost Center is a Group, \ Accounting Entries are not allowed against groups.
'; } + + cur_frm.cscript.hide_unhide_group_ledger(doc); + + cur_frm.toggle_fields('sb1', doc.group_or_ledger=='Ledger') cur_frm.set_intro(intro_txt); } @@ -80,8 +88,7 @@ cur_frm.cscript.hide_unhide_group_ledger = function(doc) { cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { $c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) { if(r.message == 1) { - refresh_field('group_or_ledger'); - cur_frm.cscript.hide_unhide_group_ledger(cur_frm.get_doc()); + cur_frm.refresh(); } }); } @@ -91,8 +98,7 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { $c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) { if(r.message == 1) { - refresh_field('group_or_ledger'); - cur_frm.cscript.hide_unhide_group_ledger(cur_frm.get_doc()); + cur_frm.refresh(); } }); } diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py index 83ad9d23cd9..99b4bac157b 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.py +++ b/erpnext/accounts/doctype/cost_center/cost_center.py @@ -14,24 +14,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see/)==-1) +msg=replace_newlines(msg);msg_dialog.set_title(title||'Message') +msg_dialog.msg_area.append(msg);msg_dialog.show();} var growl_area;function show_alert(txt,id){if(!growl_area){if(!$('#dialog-container').length){$('
No %(doctype_label)s found
\ @@ -1460,8 +1460,8 @@ return false;} /* * lib/js/wn/views/breadcrumbs.js */ -wn.provide('wn.views');wn.views.breadcrumbs=function(parent,module,doctype,name){$(parent).empty();var $bspan=$(parent);if(name){$bspan.append(''+name+'');}else if(doctype){$bspan.append(''+doctype+' List ');}else if(module){$bspan.append(''+module+'');} -if(name&&doctype&&(!locals['DocType'][doctype].issingle)){$bspan.append(repl(' in %(doctype)s List',{doctype:doctype}))};if(doctype&&module&&wn.modules&&wn.modules[module]){$bspan.append(repl(' in %(module)s',{module:module,module_page:wn.modules[module]}))}} +wn.provide('wn.views');wn.views.breadcrumbs=function(appframe,module,doctype,name){appframe.clear_breadcrumbs();if(name){appframe.add_breadcrumb(name);}else if(doctype){appframe.add_breadcrumb(doctype+' List');}else if(module){appframe.add_breadcrumb(module);} +if(name&&doctype&&(!locals['DocType'][doctype].issingle)){appframe.add_breadcrumb(repl(' in %(doctype)s List',{doctype:doctype}))};if(doctype&&module&&wn.modules&&wn.modules[module]){appframe.add_breadcrumb(repl(' in %(module)s',{module:module,module_page:wn.modules[module]}))}} /* * lib/js/legacy/widgets/form/fields.js */ @@ -1694,8 +1694,8 @@ d.cur_frm=f;d.dn=dn;d.table_form=f.meta.istable;f.refresh(dn);$(f.page_layout.wr * lib/js/legacy/widgets/form/form_header.js */ _f.FrmHeader=Class.extend({init:function(parent,frm){this.appframe=new wn.ui.AppFrame(parent) -this.appframe.$titlebar.append('\ - ');this.$w=this.appframe.$w;},refresh:function(){wn.views.breadcrumbs($(this.$w.find('.breadcrumb-area')),cur_frm.meta.module,cur_frm.meta.name,cur_frm.docname);this.refresh_labels();this.refresh_toolbar();},refresh_labels:function(){var labinfo={0:['Saved','label-success'],1:['Submitted','label-info'],2:['Cancelled','label-important']}[cint(cur_frm.doc.docstatus)];if(labinfo[0]=='Saved'&&cur_frm.meta.is_submittable){labinfo[0]='Saved, to Submit';} +this.$w=this.appframe.$w;},refresh:function(){if(cur_frm.cscript.set_breadcrumbs){this.appframe.clear_breadcrumbs();cur_frm.cscript.set_breadcrumbs();}else{wn.views.breadcrumbs(this.appframe,cur_frm.meta.module,cur_frm.meta.name,cur_frm.docname);} +this.refresh_labels();this.refresh_toolbar();},refresh_labels:function(){var labinfo={0:['Saved','label-success'],1:['Submitted','label-info'],2:['Cancelled','label-important']}[cint(cur_frm.doc.docstatus)];if(labinfo[0]=='Saved'&&cur_frm.meta.is_submittable){labinfo[0]='Saved, to Submit';} if(cur_frm.doc.__unsaved||cur_frm.doc.__islocal){labinfo[0]='Not Saved';labinfo[1]='label-warning'} this.set_label(labinfo);if(cur_frm.doc.__unsaved&&cint(cur_frm.doc.docstatus)==1&&this.appframe.buttons['Update']){this.appframe.buttons['Update'].toggle(true);}},set_label:function(labinfo){this.$w.find('.label').remove();$(repl('\ %(lab_status)s',{lab_status:labinfo[0],lab_class:labinfo[1]})).insertBefore(this.$w.find('.breadcrumb-area'))},refresh_toolbar:function(){this.appframe.clear_buttons();var p=cur_frm.get_doc_perms();if(cur_frm.meta.read_only_onload&&!cur_frm.doc.__islocal){if(!cur_frm.editable) @@ -1706,7 +1706,8 @@ if(docstatus==0&&p[SUBMIT]&&(!cur_frm.doc.__islocal)) this.appframe.add_button('Submit',function(){cur_frm.savesubmit();},'icon-lock');if(docstatus==1&&p[SUBMIT]){this.appframe.add_button('Update',function(){cur_frm.saveupdate();},'');if(!cur_frm.doc.__unsaved)this.appframe.buttons['Update'].toggle(false);} if(docstatus==1&&p[CANCEL]) this.appframe.add_button('Cancel',function(){cur_frm.savecancel()},'icon-remove');if(docstatus==2&&p[AMEND]) -this.appframe.add_button('Amend',function(){cur_frm.amend_doc()},'icon-pencil');},show:function(){},hide:function(){},hide_close:function(){this.$w.find('.close').toggle(false);}}) +this.appframe.add_button('Amend',function(){cur_frm.amend_doc()},'icon-pencil');if(cur_frm.meta.description){this.appframe.add_help_button(wn.markdown('## '+cur_frm.doctype+'\n/)==-1)txt='
'+txt+'
';this.intro_area.html(txt);}else{this.intro_area.remove();this.intro_area=null;}} _f.Frm.prototype.setup_fields_std=function(){var fl=wn.meta.docfield_list[this.doctype];fl.sort(function(a,b){return a.idx-b.idx});if(fl[0]&&fl[0].fieldtype!="Section Break"||get_url_arg('embed')){this.layout.addrow();if(fl[0].fieldtype!="Column Break"){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}} var sec;for(var i=0;iModified:
\
\
- %(modified)s
/)==-1) +msg=replace_newlines(msg);msg_dialog.set_title(title||'Message') +msg_dialog.msg_area.append(msg);msg_dialog.show();} var growl_area;function show_alert(txt,id){if(!growl_area){if(!$('#dialog-container').length){$('