From 1f4aeab85ca6fb26c7d0bd3e901edf4715471f1d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 Feb 2012 14:14:20 +0530 Subject: [PATCH 01/81] error fixed in label_cleanup --- erpnext/patches/jan_mar_2012/label_cleanup.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/patches/jan_mar_2012/label_cleanup.py b/erpnext/patches/jan_mar_2012/label_cleanup.py index 885c83f94b..a6aae9ad55 100644 --- a/erpnext/patches/jan_mar_2012/label_cleanup.py +++ b/erpnext/patches/jan_mar_2012/label_cleanup.py @@ -3,14 +3,14 @@ def execute(): from webnotes.model import delete_doc from webnotes.modules.module_manager import reload_doc - dt = [ + dt = { 'selling': ['quotation', 'sales_order', 'quotation_detail', 'sales_order_detail'], 'stock': ['delivery_note', 'delivery_note_detail', 'purchase_receipt', 'purchase_receipt_detail'], 'accounts': ['receivable_voucher', 'payable_voucher', 'rv_detail', 'pv_detail', 'rv_tax_detail', 'purchase_tax_detail'], 'buying': ['purchase_order', 'po_detail'] - ] + } for m in dt: - for d in m: + for d in dt[m]: reload_doc(m, 'doctype', d) @@ -21,7 +21,7 @@ def execute(): del_flds = { 'Sales Order Detail': "'delivery_date', 'confirmation_date'", - 'Delivery Note': "'supplier', 'supplier_address', 'purchase_receipt_no', 'purchase_order_no', 'transaction_date'" + 'Delivery Note': "'supplier', 'supplier_address', 'purchase_receipt_no', 'purchase_order_no', 'transaction_date'", 'Receivable Voucher': "'voucher_date'", 'Payable Voucher': "'voucher_date'", 'Purchase Receipt': "'transaction_date'" @@ -39,4 +39,4 @@ def execute(): webnotes.conn.sql("delete from `tabDocField` where label in (%s) and parent = %s", (del_labels[d], d)) delete_doc('DocType', 'Update Delivery Date Detail') - delete_doc('DocType', 'Update Delivery Date' + From da27db4c7d46e37d65c57d14c384b873ce4b94b3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 28 Feb 2012 12:17:08 +0100 Subject: [PATCH 02/81] fix in session stopper error display --- index.cgi | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/index.cgi b/index.cgi index e7a1d57661..301f395d44 100755 --- a/index.cgi +++ b/index.cgi @@ -38,10 +38,25 @@ def init(): # init request try: webnotes.http_request = webnotes.auth.HTTPRequest() + return True except webnotes.AuthenticationError, e: pass except webnotes.UnknownDomainError, e: print "Location: " + (webnotes.defs.redirect_404) + except webnotes.SessionStopped, e: + if 'cmd' in webnotes.form_dict: + webnotes.handler.print_json() + else: + print "Content-Type: text/html" + print + print """ + +

+ Updating. + We will be back in a few moments... +

+ + """ def respond(): import webnotes @@ -55,5 +70,5 @@ def respond(): print webnotes.cms.index.get() if __name__=="__main__": - init() - respond() + if init(): + respond() From aaf86ba4ef3c63669b86f9dffe332676a3fefcac Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 28 Feb 2012 17:40:13 +0530 Subject: [PATCH 03/81] added users --- css/all-app.css | 2 +- css/all-web.css | 2 +- erpnext/home/page/my_company/my_company.js | 250 ------------ .../doctype/customer_issue/customer_issue.py | 1 + erpnext/utilities/page/messages/messages.js | 16 + erpnext/utilities/page/messages/messages.py | 16 + erpnext/utilities/page/todo/todo.js | 16 + erpnext/utilities/page/todo/todo.py | 16 + erpnext/utilities/page/users/__init__.py | 0 erpnext/utilities/page/users/users.css | 35 ++ erpnext/utilities/page/users/users.html | 13 + erpnext/utilities/page/users/users.js | 377 ++++++++++++++++++ erpnext/utilities/page/users/users.py | 192 +++++++++ erpnext/utilities/page/users/users.txt | 28 ++ version.num | 2 +- 15 files changed, 713 insertions(+), 253 deletions(-) create mode 100644 erpnext/utilities/page/users/__init__.py create mode 100644 erpnext/utilities/page/users/users.css create mode 100644 erpnext/utilities/page/users/users.html create mode 100644 erpnext/utilities/page/users/users.js create mode 100644 erpnext/utilities/page/users/users.py create mode 100644 erpnext/utilities/page/users/users.txt diff --git a/css/all-app.css b/css/all-app.css index b2fd2e5732..b49caedee9 100644 --- a/css/all-app.css +++ b/css/all-app.css @@ -1043,7 +1043,7 @@ div.dialog_head { } div.dialog_body { - padding: 8px 4px 16px 4px; + padding: 8px 8px 16px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; diff --git a/css/all-web.css b/css/all-web.css index 9359de898e..bebfe9a334 100644 --- a/css/all-web.css +++ b/css/all-web.css @@ -362,7 +362,7 @@ div.dialog_head { } div.dialog_body { - padding: 8px 4px 16px 4px; + padding: 8px 8px 16px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; diff --git a/erpnext/home/page/my_company/my_company.js b/erpnext/home/page/my_company/my_company.js index 775c89e7a8..8217cc71c1 100644 --- a/erpnext/home/page/my_company/my_company.js +++ b/erpnext/home/page/my_company/my_company.js @@ -758,253 +758,3 @@ MemberCoversationComment = function(cell, det, conv) { -// ========================== Role object ===================================== - -pscript.all_roles = null; - -RoleObj = function(profile_id){ - this.roles_dict = {}; - this.profile_id = profile_id; - this.setup_done = 0; - - var d = new Dialog(500,500,'Assign Roles'); - d.make_body([ - ['HTML','roles'] - ]); - - this.dialog = d; - this.make_role_body(profile_id); - this.make_help_body(); - - this.body.innerHTML = 'Loading... ' - var me=this; - - d.onshow = function() { - if(!me.setup_done) - me.get_all_roles(me.profile_id); - } -} - -// make role body -RoleObj.prototype.make_role_body = function(id){ - var me = this; - var d = this.dialog; - this.role_div = $a(d.widgets['roles'],'div'); - - this.head = $a(this.role_div,'div','',{marginLeft:'4px', marginBottom:'4px',fontWeight:'bold'}); - this.body = $a(this.role_div,'div'); - this.footer = $a(this.role_div,'div'); - - this.update_btn = $btn(this.footer,'Update',function() { me.update_roles(me.profile_id); },{marginRight:'4px'},'',1); -} - -// make help body -RoleObj.prototype.make_help_body = function(){ - var me = this; - - var d = this.dialog; - this.help_div = $a(d.widgets['roles'],'div'); - - var head = $a(this.help_div,'div'); this.help_div.head = head; - var body = $a(this.help_div,'div'); this.help_div.body = body; - var tail = $a(this.help_div,'div'); this.help_div.tail = tail; - - var back_btn = $btn(tail,'Back', function() { - // back to assign roles - $(me.role_div).slideToggle('medium'); - $(me.help_div).slideToggle('medium'); - }); - this.help_div.back_btn = back_btn; - $dh(this.help_div); -} - -// get all roles -RoleObj.prototype.get_all_roles = function(id){ - if(pscript.all_roles) { - this.make_roles(id); - return; - } - - var me = this; - var callback = function(r,rt){ - pscript.all_roles = r.message; - me.make_roles(id); - } - $c_obj('Company Control','get_all_roles','',callback); -} - -// make roles -RoleObj.prototype.make_roles = function(id){ - var me = this; - var list = pscript.all_roles; - me.setup_done = 1; - me.body.innerHTML = ''; - - var tbl = make_table( me.body, cint(list.length / 2) + 1,4,'100%',['5%','45%','5%','45%'],{padding:'4px'}); - var in_right = 0; var ridx = 0; - - for(i=0;i 1){ - var c = confirm("You have unchecked the System Manager role.\nYou will lose administrative rights and will not be able to set roles.\n\nDo you want to continue anyway?"); - if(!c) return; - } - else{ - var c = "There should be atleast one user with System Manager role."; - me.roles_dict['System Manager'].checked = 1; - } - } - me.set_roles(id); - } - $c_obj('Company Control','get_sm_count','',callback); - } - else{ - me.set_roles(id); - } -} - -// set roles -RoleObj.prototype.set_roles = function(id){ - - var me = this; - var role_list = []; - - for(d in me.roles_dict){ - if(me.roles_dict[d].checked){ - role_list.push(d); - } - } - - var callback = function(r,rt){ - me.update_btn.done_working(); - me.dialog.hide(); - } - var arg = {'usr':id, 'role_list':role_list}; - me.update_btn.set_working(); - $c_obj('Company Control','update_roles',docstring(arg), callback); - -} - -// get permission -RoleObj.prototype.get_permissions = function(role){ - var me = this; - - var callback = function(r,rt){ - $(me.help_div).slideToggle('medium'); - $(me.role_div).slideToggle('medium'); - me.set_permissions(r.message, role); - } - $c_obj('Company Control','get_permission',role,callback); -} - - -// set permission -RoleObj.prototype.set_permissions = function(perm, role){ - var me = this; - me.help_div.body.innerHTML =''; - - if(perm){ - me.help_div.head.innerHTML = 'Permissions for ' + role + ':

'; - - perm_tbl = make_table(me.help_div.body,cint(perm.length)+2,7,'100%',['30%','10%','10%','10%','10%','10%','10%'],{padding:'4px'}); - - var head_lst = ['Document','Read','Write','Create','Submit','Cancel','Amend']; - - for(var i=0; i<(head_lst.length-1);i++){ - $td(perm_tbl,0,i).innerHTML= ""+head_lst[i]+""; - } - var accept_img1 = 'lib/images/icons/accept.gif'; - var cancel_img1 = 'lib/images/icons/cancel.gif'; - - for(i=1; i
'; -} diff --git a/erpnext/support/doctype/customer_issue/customer_issue.py b/erpnext/support/doctype/customer_issue/customer_issue.py index b00a6a03c8..af839cf09f 100644 --- a/erpnext/support/doctype/customer_issue/customer_issue.py +++ b/erpnext/support/doctype/customer_issue/customer_issue.py @@ -15,6 +15,7 @@ # along with this program. If not, see . # Please edit this list and import only required elements + import webnotes from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add diff --git a/erpnext/utilities/page/messages/messages.js b/erpnext/utilities/page/messages/messages.js index 39f7974870..43adce404d 100644 --- a/erpnext/utilities/page/messages/messages.js +++ b/erpnext/utilities/page/messages/messages.js @@ -1,3 +1,19 @@ +// ERPNext - web based ERP (http://erpnext.com) +// Copyright (C) 2012 Web Notes Technologies Pvt Ltd +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + wn.provide('erpnext.messages'); wn.pages.messages.onload = function(wrapper) { diff --git a/erpnext/utilities/page/messages/messages.py b/erpnext/utilities/page/messages/messages.py index d7c60267ed..8e92ff9ec9 100644 --- a/erpnext/utilities/page/messages/messages.py +++ b/erpnext/utilities/page/messages/messages.py @@ -1,3 +1,19 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + import webnotes @webnotes.whitelist() diff --git a/erpnext/utilities/page/todo/todo.js b/erpnext/utilities/page/todo/todo.js index 77e4625fae..435002301b 100644 --- a/erpnext/utilities/page/todo/todo.js +++ b/erpnext/utilities/page/todo/todo.js @@ -1,3 +1,19 @@ +// ERPNext - web based ERP (http://erpnext.com) +// Copyright (C) 2012 Web Notes Technologies Pvt Ltd +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + wn.provide('erpnext.todo'); erpnext.todo.refresh = function() { diff --git a/erpnext/utilities/page/todo/todo.py b/erpnext/utilities/page/todo/todo.py index c10809e8bf..05d55fe4a8 100644 --- a/erpnext/utilities/page/todo/todo.py +++ b/erpnext/utilities/page/todo/todo.py @@ -1,3 +1,19 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + import webnotes from webnotes.model.doc import Document diff --git a/erpnext/utilities/page/users/__init__.py b/erpnext/utilities/page/users/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/utilities/page/users/users.css b/erpnext/utilities/page/users/users.css new file mode 100644 index 0000000000..1a85d153c0 --- /dev/null +++ b/erpnext/utilities/page/users/users.css @@ -0,0 +1,35 @@ +.user-card { + border-radius: 5px; + width: 200px; + margin: 11px; + padding: 11px; + background-color: #FFEDBD; + box-shadow: 3px 3px 5px #888; + float: left; + overflow: hidden; +} + +.user-card.disabled { + background-color: #eee; +} + +.user-card img { + height: 60px; +} + +.user-role { + padding: 5px; + width: 45%; + float: left; +} + +table.user-perm { + border-collapse: collapse; +} + +table.user-perm td, table.user-perm th { + padding: 5px; + text-align: center; + border-bottom: 1px solid #aaa; + min-width: 30px; +} \ No newline at end of file diff --git a/erpnext/utilities/page/users/users.html b/erpnext/utilities/page/users/users.html new file mode 100644 index 0000000000..fe2f000413 --- /dev/null +++ b/erpnext/utilities/page/users/users.html @@ -0,0 +1,13 @@ +
+ × +

Users

+
+
Add, disable, delete users and change their roles, passwords and security settings
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/erpnext/utilities/page/users/users.js b/erpnext/utilities/page/users/users.js new file mode 100644 index 0000000000..21519b85a1 --- /dev/null +++ b/erpnext/utilities/page/users/users.js @@ -0,0 +1,377 @@ +// ERPNext - web based ERP (http://erpnext.com) +// Copyright (C) 2012 Web Notes Technologies Pvt Ltd +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +$.extend(wn.pages.users, { + onload: function(wrapper) { + wn.pages.users.profiles = {}; + wn.pages.users.refresh(); + wn.pages.users.setup(); + wn.pages.users.role_editor = new erpnext.RoleEditor(); + }, + setup: function() { + // set roles + $('.users-area').on('click', '.btn.user-roles', function() { + var uid = $(this).parent().parent().attr('data-name'); + wn.pages.users.role_editor.show(uid); + }); + + // settings + $('.users-area').on('click', '.btn.user-settings', function() { + var uid = $(this).parent().parent().attr('data-name'); + wn.pages.users.show_settings(uid); + }); + + // delete + $('.users-area').on('click', 'a.close', function() { + $card = $(this).parent(); + var uid = $card.attr('data-name'); + $card.css('opacity', 0.6); + wn.call({ + method: 'utilities.page.users.users.delete', + args: {'uid': uid}, + callback: function(r,rt) { + if(!r.exc) + $card.fadeOut() + } + }); + }) + + }, + refresh: function() { + // make the list + wn.call({ + method:'utilities.page.users.users.get', + callback: function(r, rt) { + $('.users-area').empty(); + for(var i in r.message) { + var p = r.message[i]; + wn.pages.users.profiles[p.name] = p; + wn.pages.users.render(p); + } + } + }); + }, + render: function(data) { + if(data.file_list) { + data.imgsrc = 'files/' + data.files_list.split('\n')[0].split(',')[1]; + } else { + data.imgsrc = 'lib/images/ui/no_img_' + (data.gender=='Female' ? 'f' : 'm'); + } + data.fullname = wn.boot.user_fullnames[data.name]; + data.delete_html = ''; + if(!data.enabled) + data.delete_html = '×'; + + $('.users-area').append(repl('
\ + %(delete_html)s\ + \ + \ +
', data)); + + if(!data.enabled) { + $('.users-area .user-card:last') + .addClass('disabled') + .find('.user-fullname').html('Disabled'); + } + }, + show_settings: function(uid) { + var me = wn.pages.users; + if(!me.settings_dialog) + me.make_settings_dialog(); + + var p = me.profiles[uid]; + me.uid = uid; + + me.settings_dialog.set_values({ + restrict_ip: p.restrict_ip || '', + login_before: p.login_before || '', + login_after: p.login_after || '', + enabled: p.enabled || 0, + new_password: '' + }); + + me.settings_dialog.show(); + + }, + make_settings_dialog: function() { + var me = wn.pages.users; + me.settings_dialog = new wn.widgets.Dialog({ + title: 'Set User Security', + width: 500, + fields: [ + { + label:'Enabled', + description: 'Uncheck to disable', + fieldtype: 'Check', fieldname: 'enabled' + }, + { + label:'IP Address', + description: 'Restrict user login by IP address, partial ips (111.111.111), \ + multiple addresses (separated by commas) allowed', + fieldname:'restrict_ip', fieldtype:'Data' + }, + { + label:'Login After', + description: 'User can only login after this hour (0-24)', + fieldtype: 'Int', fieldname: 'login_after' + }, + { + label:'Login Before', + description: 'User can only login before this hour (0-24)', + fieldtype: 'Int', fieldname: 'login_before' + }, + { + label:'New Password', + description: 'Update the current user password', + fieldtype: 'Data', fieldname: 'new_password' + }, + { + label:'Update', fieldtype:'Button', fieldname:'update' + } + ] + }); + + this.settings_dialog.fields_dict.update.input.onclick = function() { + var btn = this; + this.set_working(); + var args = me.settings_dialog.get_values(); + args.user = me.uid; + + if (args.new_password) { + me.get_password(btn, args); + } else { + btn.set_working(); + me.update_security(args); + } + }; + + }, + update_security: function(args) { + var me = wn.pages.users; + $c_page('utilities', 'users', 'update_security', JSON.stringify(args), function(r,rt) { + if(r.exc) { + msgprint(r.exc); + return; + } + me.settings_dialog.hide(); + $.extend(me.profiles[me.uid], me.settings_dialog.get_values()); + me.refresh(); + }); + }, + get_password: function(btn, args) { + var me = wn.pages.users; + var pass_d = new wn.widgets.Dialog({ + title: 'Your Password', + width: 300, + fields: [ + { + label: 'Please Enter Your Password', + description: "Your password is required to update the user's password", + fieldtype: 'Password', fieldname: 'sys_admin_pwd', reqd: 1 + }, + { + label: 'Continue', fieldtype: 'Button', fieldname: 'continue' + } + ] + }); + + pass_d.fields_dict.continue.input.onclick = function() { + btn.pwd_dialog.hide(); + args.sys_admin_pwd = btn.pwd_dialog.get_values().sys_admin_pwd; + btn.set_working(); + me.update_security(args); + btn.done_working(); + } + + pass_d.show(); + btn.pwd_dialog = pass_d; + btn.done_working(); + }, + add_user: function() { + var me = wn.pages.users; + var d = new wn.widgets.Dialog({ + title: 'Add User', + width: 400, + fields: [{ + fieldtype: 'Data', fieldname: 'user', reqd: 1, + label: 'Email Id of the user to add' + }, { + fieldtype: 'Data', fieldname: 'first_name', reqd: 1, label: 'First Name' + }, { + fieldtype: 'Data', fieldname: 'last_name', label: 'Last Name' + }, { + fieldtype: 'Data', fieldname: 'password', reqd: 1, label: 'Password' + }, { + fieldtype: 'Button', label: 'Add', fieldname: 'add' + }] + }); + + d.make(); + d.fields_dict.add.input.onclick = function() { + v = d.get_values(); + if(v) { + d.fields_dict.add.input.set_working(); + $c_page('utilities', 'users', 'add_user', v, function(r,rt) { + if(r.exc) { msgprint(r.exc); return; } + else { + d.hide(); + me.refresh(); + } + }) + } + } + d.show(); + } +}); + +erpnext.RoleEditor = Class.extend({ + init: function() { + this.dialog = new wn.widgets.Dialog({ + title: 'Set Roles' + }); + var me = this; + $(this.dialog.body).html('
Loading...
') + wn.call({ + method:'utilities.page.users.users.get_roles', + callback: function(r) { + me.roles = r.message; + me.show_roles(); + } + }); + }, + show_roles: function() { + var me = this; + $(this.dialog.body).empty(); + for(var i in this.roles) { + $(this.dialog.body).append(repl('
\ + \ + %(role)s\ +
', {role: this.roles[i]})); + } + $(this.dialog.body).append('
\ +
'); + $(this.dialog.body).find('button.btn-primary').click(function() { + me.save(); + }); + $(this.dialog.body).find('.user-role a').click(function() { + me.show_permissions($(this).parent().attr('data-user-role')) + return false; + }) + }, + show: function(uid) { + var me = this; + this.uid = uid; + this.dialog.show(); + // set user roles + wn.call({ + method:'utilities.page.users.users.get_user_roles', + args: {uid:uid}, + callback: function(r, rt) { + $(me.dialog.body).find('input[type="checkbox"]').attr('checked', false); + for(var i in r.message) { + $(me.dialog.body) + .find('[data-user-role="'+r.message[i] + +'"] input[type="checkbox"]').attr('checked',true); + } + } + }) + }, + save: function() { + var set_roles = []; + var unset_roles = []; + $(this.dialog.body).find('[data-user-role]').each(function() { + var $check = $(this).find('input[type="checkbox"]'); + if($check.attr('checked')) { + set_roles.push($(this).attr('data-user-role')); + } else { + unset_roles.push($(this).attr('data-user-role')); + } + }) + wn.call({ + method:'utilities.page.users.users.update_roles', + args: { + set_roles: JSON.stringify(set_roles), + unset_roles: JSON.stringify(unset_roles), + uid: this.uid + }, + btn: $(this.dialog.body).find('.btn-primary').get(0), + callback: function() { + + } + }) + }, + show_permissions: function(role) { + // show permissions for a role + var me = this; + if(!this.perm_dialog) + this.make_perm_dialog() + $(this.perm_dialog.body).empty(); + wn.call({ + method:'utilities.page.users.users.get_perm_info', + args: {role: role}, + callback: function(r) { + var $body = $(me.perm_dialog.body); + $body.append('\ + \ + \ + \ + \ + \ + \ +
Document TypeLevelReadWriteSubmitCancelAmend
'); + for(var i in r.message) { + var perm = r.message[i]; + + // if permission -> icon + for(key in perm) { + if(key!='parent' && key!='permlevel') { + if(perm[key]) { + perm[key] = ''; + } else { + perm[key] = ''; + } + } + } + + $body.find('tbody').append(repl('\ + %(parent)s\ + %(permlevel)s\ + %(read)s\ + %(write)s\ + %(submit)s\ + %(cancel)s\ + %(amend)s\ + ', perm)) + } + + me.perm_dialog.show(); + } + }); + + }, + make_perm_dialog: function() { + this.perm_dialog = new wn.widgets.Dialog({ + title:'Role Permissions', + width: 500 + }); + } +}) diff --git a/erpnext/utilities/page/users/users.py b/erpnext/utilities/page/users/users.py new file mode 100644 index 0000000000..44e2fb2aac --- /dev/null +++ b/erpnext/utilities/page/users/users.py @@ -0,0 +1,192 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import webnotes +import json + +from webnotes.model.doc import Document +from webnotes.utils import cint + +@webnotes.whitelist() +def get(arg=None): + """return all users""" + return webnotes.conn.sql("""select name, file_list, enabled, gender, + restrict_ip, login_before, login_after from tabProfile + where docstatus<2 and name not in ('Administrator', 'Guest') order by + ifnull(enabled,0) desc, name""", as_dict=1) + +@webnotes.whitelist() +def get_roles(arg=None): + """return all roles""" + return [r[0] for r in webnotes.conn.sql("""select name from tabRole + where name not in ('Administrator', 'Guest', 'All') order by name""")] + +@webnotes.whitelist() +def get_user_roles(arg=None): + """get roles for a user""" + return [r[0] for r in webnotes.conn.sql("""select role from tabUserRole + where parent=%s""", webnotes.form_dict['uid'])] + +@webnotes.whitelist() +def get_perm_info(arg=None): + """get permission info""" + return webnotes.conn.sql("""select parent, permlevel, `read`, `write`, submit, + cancel, amend from tabDocPerm where role=%s + and docstatus<2 order by parent, permlevel""", + webnotes.form_dict['role'], as_dict=1) + +@webnotes.whitelist() +def update_roles(arg=None): + """update set and unset roles""" + # remove roles + unset = json.loads(webnotes.form_dict['unset_roles']) + webnotes.conn.sql("""delete from tabUserRole where parent='%s' + and role in ('%s')""" % (webnotes.form_dict['uid'], "','".join(unset))) + + # check for 1 system manager + if not webnotes.conn.sql("""select parent from tabUserRole where role='System Manager' + and docstatus<2"""): + webnotes.msgprint("Sorry there must be atleast one 'System Manager'") + raise webnotes.ValidationError + + # add roles + roles = get_user_roles() + toset = json.loads(webnotes.form_dict['set_roles']) + for role in toset: + if not role in roles: + d = Document('UserRole') + d.role = role + d.parent = webnotes.form_dict['uid'] + d.save() + + webnotes.msgprint('Roles Updated') + +@webnotes.whitelist() +def update_security(args=''): + args = json.loads(args) + webnotes.conn.set_value('Profile', args['user'], 'restrict_ip', args.get('restrict_ip')) + webnotes.conn.set_value('Profile', args['user'], 'login_after', args.get('login_after')) + webnotes.conn.set_value('Profile', args['user'], 'login_before', args.get('login_before')) + webnotes.conn.set_value('Profile', args['user'], 'enabled', int(args.get('enabled',0)) or 0) + + if 'new_password' in args: + if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')): + import server_tools.gateway_utils + res = server_tools.gateway_utils.change_password('', args['new_password'], + args['user'], args['sys_admin_pwd']) + if 'Traceback' not in res['message']: + webnotes.msgprint(res['message']) + webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", + (args['new_password'], args['user'])) + else: + webnotes.msgprint('Settings Updated') + + + +# +# user addition +# + +@webnotes.whitelist() +def add_user(args): + args = json.loads(args) + # erpnext-saas + if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')): + from server_tools.gateway_utils import add_user_gateway + add_user_gateway(args['user']) + + add_profile(args) + +@webnotes.whitelist() +def add_profile(args): + from webnotes.utils import validate_email_add, now + email = args['user'] + + sql = webnotes.conn.sql + + if not email: + email = webnotes.form_dict.get('user') + if not validate_email_add(email): + raise Exception + return 'Invalid Email Id' + + if sql("select name from tabProfile where name = %s", email): + # exists, enable it + sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email) + webnotes.msgprint('Profile exists, enabled it with new password') + else: + # does not exist, create it! + pr = Document('Profile') + pr.name = email + pr.email = email + pr.first_name = args.get('first_name') + pr.last_name = args.get('last_name') + pr.enabled = 1 + pr.user_type = 'System User' + pr.save(1) + + if args.get('password'): + sql(""" + UPDATE tabProfile + SET password = PASSWORD(%s), modified = %s + WHERE name = %s""", (args.get('password'), now, email)) + + send_welcome_mail(email, args) + +@webnotes.whitelist() +def send_welcome_mail(email, args): + """send welcome mail to user with password and login url""" + pr = Document('Profile', email) + from webnotes.utils.email_lib import sendmail_md + args.update({ + 'company': webnotes.conn.get_default('company'), + 'password': args.get('password'), + 'account_url': webnotes.conn.get_default('account_url') + }) + if not args.get('last_name'): args['last_name'] = '' + sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args, from_defs=1) + +# +# delete user +# +@webnotes.whitelist() +def delete(arg=None): + """delete user""" + webnotes.conn.sql("update tabProfile set enabled=0, docstatus=2 where name=%s", + webnotes.form_dict['uid']) + # erpnext-saas + if int(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')): + from server_tools.gateway_utils import remove_user_gateway + remove_user_gateway(webnotes.form_dict['uid']) + + webnotes.login_manager.logout(user=webnotes.form_dict['uid']) + +welcome_txt = """ +## %(company)s + +Dear %(first_name)s %(last_name)s + +Welcome! + +A new account has been created for you, here are your details: + +login-id: %(user)s +password: %(password)s + +To login to your new ERPNext account, please go to: + +%(account_url)s +""" \ No newline at end of file diff --git a/erpnext/utilities/page/users/users.txt b/erpnext/utilities/page/users/users.txt new file mode 100644 index 0000000000..165cc1695b --- /dev/null +++ b/erpnext/utilities/page/users/users.txt @@ -0,0 +1,28 @@ +# Page, users +[ + + # These values are common in all dictionaries + { + 'creation': '2012-02-28 10:29:39', + 'docstatus': 0, + 'modified': '2012-02-28 10:29:39', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Page + { + 'doctype': 'Page', + 'module': u'Utilities', + 'name': '__common__', + 'page_name': u'users', + 'standard': u'Yes', + 'title': u'Users' + }, + + # Page, users + { + 'doctype': 'Page', + 'name': u'users' + } +] \ No newline at end of file diff --git a/version.num b/version.num index 8c28da60d7..5cd7ca2206 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -747 \ No newline at end of file +748 \ No newline at end of file From d01cc0bc508916117a7e7319e2a70a3664b89871 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 28 Feb 2012 17:45:08 +0530 Subject: [PATCH 04/81] messages and merge --- version.num | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/version.num b/version.num index 37e7ba980b..5cd7ca2206 100644 --- a/version.num +++ b/version.num @@ -1,5 +1 @@ -<<<<<<< HEAD -748 -======= -747 ->>>>>>> da27db4c7d46e37d65c57d14c384b873ce4b94b3 +748 \ No newline at end of file From 17da764d04327ffdb8950baaad0c05c95e41b461 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 28 Feb 2012 18:56:56 +0530 Subject: [PATCH 05/81] modules_setup --- erpnext/home/page/desktop/desktop.js | 67 +++++++++++++------ erpnext/setup/page/modules_setup/__init__.py | 0 .../page/modules_setup/modules_setup.css | 0 .../page/modules_setup/modules_setup.html | 14 ++++ .../setup/page/modules_setup/modules_setup.js | 50 ++++++++++++++ .../setup/page/modules_setup/modules_setup.py | 8 +++ .../page/modules_setup/modules_setup.txt | 28 ++++++++ erpnext/setup/page/setup/setup.html | 6 +- erpnext/startup/event_handlers.py | 2 + erpnext/startup/toolbar.js | 41 ++++++++---- js/all-app.js | 22 +++--- js/all-web.js | 2 +- version.num | 2 +- 13 files changed, 192 insertions(+), 50 deletions(-) create mode 100644 erpnext/setup/page/modules_setup/__init__.py create mode 100644 erpnext/setup/page/modules_setup/modules_setup.css create mode 100644 erpnext/setup/page/modules_setup/modules_setup.html create mode 100644 erpnext/setup/page/modules_setup/modules_setup.js create mode 100644 erpnext/setup/page/modules_setup/modules_setup.py create mode 100644 erpnext/setup/page/modules_setup/modules_setup.txt diff --git a/erpnext/home/page/desktop/desktop.js b/erpnext/home/page/desktop/desktop.js index e2a8d5386e..ebd3da1dda 100644 --- a/erpnext/home/page/desktop/desktop.js +++ b/erpnext/home/page/desktop/desktop.js @@ -44,35 +44,60 @@ erpnext.desktop.add_classes = function() { erpnext.desktop.render = function() { var icons = [ - { gradient: 'brown', sprite: 'feed', label: 'Activity', link: '#!Event Updates' }, - { gradient: 'blue', sprite: 'account', label: 'Accounts', link: '#!accounts-home' }, - { gradient: 'green', sprite: 'selling', label: 'Selling', link: '#!selling-home' }, - { gradient: 'yellow', sprite: 'stock', label: 'Stock', link: '#!stock-home' }, - { gradient: 'red', sprite: 'buying', label: 'Buying', link: '#!buying-home' }, - { gradient: 'purple', sprite: 'support', label: 'Support', link: '#!support-home' }, - { gradient: 'ocean', sprite: 'hr', label: 'Human
Resources', link: '#!hr-home' }, - { gradient: 'violet', sprite: 'project', label: 'Projects', link: '#!projects-home' }, - { gradient: 'dark-red', sprite: 'production', label: 'Production', link: '#!production-home' }, - { gradient: 'leaf-green', sprite: 'website', label: 'Website', link: '#!website-home' }, - { gradient: 'grey', sprite: 'setting', label: 'Settings', link: '#!Setup' }, - { gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard', link: '#!dashboard' }, - //{ gradient: 'dark-blue', sprite: 'report', label: 'Report' }, - { gradient: 'pink', sprite: 'messages', label: 'Messages', link: '#!messages' }, - { gradient: 'bright-yellow', sprite: 'todo', label: 'To Do', link: '#!todo' }, - { gradient: 'peacock', sprite: 'calendar', label: 'Calendar', link: '#!calendar' }, - { gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge
Base', link: '#!questions' }, + { gradient: 'blue', sprite: 'account', label: 'Accounts', link: '#!accounts-home', + is_module: 'Accounts'}, + { gradient: 'green', sprite: 'selling', label: 'Selling', link: '#!selling-home', + is_module: 'Selling'}, + { gradient: 'yellow', sprite: 'stock', label: 'Stock', link: '#!stock-home', + is_module: 'Stock'}, + { gradient: 'red', sprite: 'buying', label: 'Buying', link: '#!buying-home', + is_module: 'Buying'}, + { gradient: 'purple', sprite: 'support', label: 'Support', link: '#!support-home', + is_module: 'Support'}, + { gradient: 'ocean', sprite: 'hr', label: 'Human
Resources', link: '#!hr-home', + is_module: 'HR'}, + { gradient: 'violet', sprite: 'project', label: 'Projects', link: '#!projects-home', + is_module: 'Projects'}, + { gradient: 'dark-red', sprite: 'production', label: 'Production', link: '#!production-home', + is_module: 'Production'}, + { gradient: 'leaf-green', sprite: 'website', label: 'Website', link: '#!website-home', + is_module: 'Website'}, ] - $.each(icons, function(i, v) { - var icon_case = $('#icon-grid').append(repl('\ + var add_icon = function(v) { + $('#icon-grid').append(repl('\
\
\
\
\
%(label)s
\ -
', v)); - }); + ', v)); + } + + var get_module = function(m) { + for(var i in icons) { + if(icons[i].is_module==m) return icons[i] + } + } + + // activity + add_icon({ gradient: 'brown', sprite: 'feed', label: 'Activity', link: '#!Event Updates'}); + // modules + for(var i in wn.boot.modules_list) + add_icon(get_module(wn.boot.modules_list[i])); + + // setup + if(user_roles.indexOf('System Manager')!=-1) + add_icon({ gradient: 'grey', sprite: 'setting', label: 'Setup', link: '#!Setup' }); + + // apps + add_icon({ gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard', link: '#!dashboard' }); + add_icon({ gradient: 'bright-yellow', sprite: 'todo', label: 'To Do', link: '#!todo' }); + add_icon({ gradient: 'pink', sprite: 'messages', label: 'Messages', link: '#!messages' }); + add_icon({ gradient: 'peacock', sprite: 'calendar', label: 'Calendar', link: '#!calendar' }); + add_icon({ gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge
Base', link: '#!questions' }); + erpnext.desktop.show_pending_notifications(); } diff --git a/erpnext/setup/page/modules_setup/__init__.py b/erpnext/setup/page/modules_setup/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/setup/page/modules_setup/modules_setup.css b/erpnext/setup/page/modules_setup/modules_setup.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/setup/page/modules_setup/modules_setup.html b/erpnext/setup/page/modules_setup/modules_setup.html new file mode 100644 index 0000000000..ea136ffcae --- /dev/null +++ b/erpnext/setup/page/modules_setup/modules_setup.html @@ -0,0 +1,14 @@ +
+ × +

Modules Setup

+
+
+ Select checkbox to show / hide module. Drag around to move order. +
+
+
+
+ +
+
\ No newline at end of file diff --git a/erpnext/setup/page/modules_setup/modules_setup.js b/erpnext/setup/page/modules_setup/modules_setup.js new file mode 100644 index 0000000000..fe7f14fad3 --- /dev/null +++ b/erpnext/setup/page/modules_setup/modules_setup.js @@ -0,0 +1,50 @@ +wn.require('lib/js/lib/jquery-ui-sortable.min.js'); + +$.extend(wn.pages.modules_setup, { + modules: ['Accounts', 'Selling', 'Buying', 'Stock', 'Production', 'Projects', + 'Support', 'HR', 'Website'], + onload: function(wrapper) { + wn.pages.modules_setup.refresh(wn.boot.modules_list); + }, + refresh: function(ml) { + $('#modules-list').empty(); + + // checked modules + for(i in ml) { + $('#modules-list').append(repl('

\ + \ + %(m)s

', {m:ml[i]})); + } + $('#modules-list [data-module]').attr('checked', true); + + // unchecked modules + var all = wn.pages.modules_setup.modules; + for(i in all) { + if(!$('#modules-list [data-module="'+all[i]+'"]').length) { + $('#modules-list').append(repl('

\ + \ + %(m)s

', {m:all[i]})); + } + } + + $('#modules-list').sortable(); + + }, + update: function() { + var ml = []; + $('#modules-list [data-module]').each(function() { + if($(this).attr('checked')) + ml.push($(this).attr('data-module')); + }); + + wn.call({ + method: 'setup.page.modules_setup.modules_setup.update', + args: { + ml: JSON.stringify(ml) + }, + callback: function(r) { + }, + btn: $('#modules-update').get(0) + }); + } +}); \ No newline at end of file diff --git a/erpnext/setup/page/modules_setup/modules_setup.py b/erpnext/setup/page/modules_setup/modules_setup.py new file mode 100644 index 0000000000..ee36dfaeaa --- /dev/null +++ b/erpnext/setup/page/modules_setup/modules_setup.py @@ -0,0 +1,8 @@ +import webnotes + +@webnotes.whitelist() +def update(arg=None): + """update modules""" + webnotes.conn.set_global('modules_list', webnotes.form_dict['ml']) + webnotes.msgprint('Updated') + webnotes.clear_cache() \ No newline at end of file diff --git a/erpnext/setup/page/modules_setup/modules_setup.txt b/erpnext/setup/page/modules_setup/modules_setup.txt new file mode 100644 index 0000000000..70c6a90cc2 --- /dev/null +++ b/erpnext/setup/page/modules_setup/modules_setup.txt @@ -0,0 +1,28 @@ +# Page, modules_setup +[ + + # These values are common in all dictionaries + { + 'creation': '2012-02-28 17:48:39', + 'docstatus': 0, + 'modified': '2012-02-28 17:48:39', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Page + { + 'doctype': 'Page', + 'module': u'Setup', + 'name': '__common__', + 'page_name': u'modules_setup', + 'standard': u'Yes', + 'title': u'Modules Setup' + }, + + # Page, modules_setup + { + 'doctype': 'Page', + 'name': u'modules_setup' + } +] \ No newline at end of file diff --git a/erpnext/setup/page/setup/setup.html b/erpnext/setup/page/setup/setup.html index 7963cb9d9a..50ef112bbb 100644 --- a/erpnext/setup/page/setup/setup.html +++ b/erpnext/setup/page/setup/setup.html @@ -20,7 +20,7 @@

Users and Permissions

- Users
+ Users
Add/remove users, set roles, passwords etc

@@ -31,6 +31,10 @@ Amount based Authorization Rules
Restrict submission rights based on amount

+

+ Modules Setup
+ Show, hide modules +

Data

diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index 5f0cc2334c..a1d805ef1f 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -87,6 +87,8 @@ def boot_session(bootinfo): import webnotes.model.doctype bootinfo['docs'] += webnotes.model.doctype.get('Event') + + bootinfo['modules_list'] = webnotes.conn.get_global('modules_list') def get_letter_heads(): """load letter heads with startup""" diff --git a/erpnext/startup/toolbar.js b/erpnext/startup/toolbar.js index 7eda49361c..8c8d04167e 100644 --- a/erpnext/startup/toolbar.js +++ b/erpnext/startup/toolbar.js @@ -73,20 +73,35 @@ erpnext.toolbar.add_modules = function() { $('
\ ',wn.boot.website_settings));this.make_items();},make_items:function(){var items=wn.boot.website_menus for(var i=0;i%(label)s',item))}}}});$(document).bind('startup',function(){erpnext.footer=new erpnext.Footer();erpnext.navbar.navbar=new erpnext.navbar.navbar();}) + data-label="%(label)s">%(label)s',item))}}}});$(document).bind('startup',function(){erpnext.footer=new erpnext.Footer();erpnext.navbar.navbar=new erpnext.navbar.navbar();}) \ No newline at end of file diff --git a/version.num b/version.num index 5cd7ca2206..e9244f999a 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -748 \ No newline at end of file +752 \ No newline at end of file From 22aa17bcce2d41050b4e0f4ca8d77f330f645f5f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 Feb 2012 10:44:27 +0530 Subject: [PATCH 06/81] changes in trend analyzer query --- .../analysis/search_criteria/trend_analyzer/trend_analyzer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.py b/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.py index ad5718154b..2198204894 100644 --- a/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.py +++ b/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.py @@ -107,7 +107,7 @@ if item or based_on == 'Item': # Item Group if item_group or based_on == 'Item Group': add_tab += ' ,`tabItem` t3, `tabItem Group` t4 ' - add_cond += ' AND t3.name = t2.item_code AND t3.item_group = t4.name and (t4.name = "%s" or t4.name IN (SELECT t5.name FROM `tabItem Group` t5,`tabItem Group` t6 WHERE t5.lft BETWEEN t6.lft and t6.rgt and t5.docstatus !=2 and ifnull(t5.is_group,"No") = "No" and t6.name = "%s"))' % (based_on != 'Item Group' and item_group or '%(value)s', based_on != 'Item Group' and item_group or '%(value)s') + add_cond += ' AND t3.name = t2.item_code AND t3.item_group = t4.name and (t4.name = "%s" or t4.name IN (SELECT t5.name FROM `tabItem Group` t5,`tabItem Group` t6 WHERE t5.lft BETWEEN t6.lft and t6.rgt and t5.docstatus !=2 and t6.name = "%s"))' % (based_on != 'Item Group' and item_group or '%(value)s', based_on != 'Item Group' and item_group or '%(value)s') # Customer if customer or based_on == 'Customer': From a38bbe28cef6ef741ac64da57b871062c438badf Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 29 Feb 2012 10:55:43 +0530 Subject: [PATCH 07/81] home page fixes --- erpnext/home/page/desktop/desktop.js | 75 ++++++++----------- .../setup/page/modules_setup/modules_setup.js | 4 +- erpnext/startup/startup.js | 18 +++++ erpnext/startup/toolbar.js | 20 ++--- index.cgi | 2 +- js/all-app.js | 11 +-- js/all-web.js | 3 +- version.num | 2 +- 8 files changed, 73 insertions(+), 62 deletions(-) diff --git a/erpnext/home/page/desktop/desktop.js b/erpnext/home/page/desktop/desktop.js index ebd3da1dda..63a075ceb2 100644 --- a/erpnext/home/page/desktop/desktop.js +++ b/erpnext/home/page/desktop/desktop.js @@ -43,61 +43,50 @@ erpnext.desktop.add_classes = function() { } erpnext.desktop.render = function() { - var icons = [ - { gradient: 'blue', sprite: 'account', label: 'Accounts', link: '#!accounts-home', - is_module: 'Accounts'}, - { gradient: 'green', sprite: 'selling', label: 'Selling', link: '#!selling-home', - is_module: 'Selling'}, - { gradient: 'yellow', sprite: 'stock', label: 'Stock', link: '#!stock-home', - is_module: 'Stock'}, - { gradient: 'red', sprite: 'buying', label: 'Buying', link: '#!buying-home', - is_module: 'Buying'}, - { gradient: 'purple', sprite: 'support', label: 'Support', link: '#!support-home', - is_module: 'Support'}, - { gradient: 'ocean', sprite: 'hr', label: 'Human
Resources', link: '#!hr-home', - is_module: 'HR'}, - { gradient: 'violet', sprite: 'project', label: 'Projects', link: '#!projects-home', - is_module: 'Projects'}, - { gradient: 'dark-red', sprite: 'production', label: 'Production', link: '#!production-home', - is_module: 'Production'}, - { gradient: 'leaf-green', sprite: 'website', label: 'Website', link: '#!website-home', - is_module: 'Website'}, - ] + var icons = { + 'Accounts': { gradient: 'blue', sprite: 'account', label: 'Accounts'}, + 'Selling': { gradient: 'green', sprite: 'selling', label: 'Selling'}, + 'Stock': { gradient: 'yellow', sprite: 'stock', label: 'Stock'}, + 'Buying': { gradient: 'red', sprite: 'buying', label: 'Buying'}, + 'Support': { gradient: 'purple', sprite: 'support', label: 'Support'}, + 'HR': { gradient: 'ocean', sprite: 'hr', label: 'Human
Resources'}, + 'Projects': { gradient: 'violet', sprite: 'project', label: 'Projects'}, + 'Production': { gradient: 'dark-red', sprite: 'production', label: 'Production'}, + 'Website': { gradient: 'leaf-green', sprite: 'website', label: 'Website'}, + 'Activity': { gradient: 'brown', sprite: 'feed', label: 'Activity'}, + 'Setup': { gradient: 'grey', sprite: 'setting', label: 'Setup'}, + 'Dashboard': { gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard'}, + 'To Do': { gradient: 'bright-yellow', sprite: 'todo', label: 'To Do'}, + 'Messages': { gradient: 'pink', sprite: 'messages', label: 'Messages'}, + 'Calendar': { gradient: 'peacock', sprite: 'calendar', label: 'Calendar'}, + 'Knowledge Base': { gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge
Base'} + } + - var add_icon = function(v) { + var add_icon = function(m) { + var icon = icons[m]; + icon.link = erpnext.modules[m]; $('#icon-grid').append(repl('\ -
\ +
\
\
\
\
%(label)s
\ -
', v)); +
', icon)); } - var get_module = function(m) { - for(var i in icons) { - if(icons[i].is_module==m) return icons[i] - } - } - - // activity - add_icon({ gradient: 'brown', sprite: 'feed', label: 'Activity', link: '#!Event Updates'}); - - // modules - for(var i in wn.boot.modules_list) - add_icon(get_module(wn.boot.modules_list[i])); - // setup + + for(var i in wn.boot.modules_list) { + var m = wn.boot.modules_list[i]; + if(m!='Setup'); + add_icon(m); + } + if(user_roles.indexOf('System Manager')!=-1) - add_icon({ gradient: 'grey', sprite: 'setting', label: 'Setup', link: '#!Setup' }); + add_icon('Setup') // apps - add_icon({ gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard', link: '#!dashboard' }); - add_icon({ gradient: 'bright-yellow', sprite: 'todo', label: 'To Do', link: '#!todo' }); - add_icon({ gradient: 'pink', sprite: 'messages', label: 'Messages', link: '#!messages' }); - add_icon({ gradient: 'peacock', sprite: 'calendar', label: 'Calendar', link: '#!calendar' }); - add_icon({ gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge
Base', link: '#!questions' }); - erpnext.desktop.show_pending_notifications(); } diff --git a/erpnext/setup/page/modules_setup/modules_setup.js b/erpnext/setup/page/modules_setup/modules_setup.js index fe7f14fad3..af7522f4ae 100644 --- a/erpnext/setup/page/modules_setup/modules_setup.js +++ b/erpnext/setup/page/modules_setup/modules_setup.js @@ -1,8 +1,8 @@ wn.require('lib/js/lib/jquery-ui-sortable.min.js'); $.extend(wn.pages.modules_setup, { - modules: ['Accounts', 'Selling', 'Buying', 'Stock', 'Production', 'Projects', - 'Support', 'HR', 'Website'], + modules: ['Activity', 'Accounts', 'Selling', 'Buying', 'Stock', 'Production', 'Projects', + 'Support', 'HR', 'Website', 'To Do', 'Messages', 'Calendar', 'Knowledge Base'], onload: function(wrapper) { wn.pages.modules_setup.refresh(wn.boot.modules_list); }, diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js index 83b1685f55..30ab28d53b 100644 --- a/erpnext/startup/startup.js +++ b/erpnext/startup/startup.js @@ -19,6 +19,24 @@ var is_system_manager = 0; wn.provide('erpnext.startup'); +erpnext.modules = { + 'Selling': 'selling-home', + 'Accounts': 'accounts-home', + 'Stock': 'stock-home', + 'Buying': 'buying-home', + 'Support': 'support-home', + 'Projects': 'projects-home', + 'Production': 'production-home', + 'Website': 'website-home', + 'HR': 'hr-home', + 'Setup': 'Setup', + 'Activity': 'Event Updates', + 'To Do': 'todo', + 'Calendar': 'calendar', + 'Messages': 'messages', + 'Knowledge Base': 'questions' +} + erpnext.startup.set_globals = function() { pscript.is_erpnext_saas = cint(wn.control_panel.sync_with_gateway) if(inList(user_roles,'System Manager')) is_system_manager = 1; diff --git a/erpnext/startup/toolbar.js b/erpnext/startup/toolbar.js index 8c8d04167e..1a2bfdfe9a 100644 --- a/erpnext/startup/toolbar.js +++ b/erpnext/startup/toolbar.js @@ -81,20 +81,22 @@ erpnext.toolbar.add_modules = function() { if(wn.boot.modules_list) wn.boot.modules_list = JSON.parse(wn.boot.modules_list); else - wn.boot.modules_list = ['Accounts', 'Selling', 'Buying', 'Stock', - 'Production', 'Projects', 'Support', 'HR', 'Website']; + wn.boot.modules_list = keys(erpnext.modules).sort(); // add to dropdown for(var i in wn.boot.modules_list) { var m = wn.boot.modules_list[i] - args = { - module: m, - module_page: m.toLowerCase(), - module_label: m=='HR' ? 'Human Resources' : m + + if(m!='Setup') { + args = { + module: m, + module_page: erpnext.modules[m], + module_label: m=='HR' ? 'Human Resources' : m + } + + $('.navbar .modules').append(repl('
  • %(module_label)s
  • ', args)); } - - $('.navbar .modules').append(repl('
  • %(module_label)s
  • ', args)); } // setup for system manager diff --git a/index.cgi b/index.cgi index 301f395d44..ed766eb11f 100755 --- a/index.cgi +++ b/index.cgi @@ -40,7 +40,7 @@ def init(): webnotes.http_request = webnotes.auth.HTTPRequest() return True except webnotes.AuthenticationError, e: - pass + return True except webnotes.UnknownDomainError, e: print "Location: " + (webnotes.defs.redirect_404) except webnotes.SessionStopped, e: diff --git a/js/all-app.js b/js/all-app.js index cd563f14c3..62d63ce67f 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -2192,7 +2192,8 @@ wn.modules_path='erpnext';wn.settings.no_history=true;$(document).bind('ready',f /* * erpnext/startup/startup.js */ -var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.startup.set_globals=function(){pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway) +var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'Event Updates','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions'} +erpnext.startup.set_globals=function(){pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway) if(inList(user_roles,'System Manager'))is_system_manager=1;} erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.custom_css){set_style(wn.boot.custom_css);} if(user=='Guest'){if(wn.boot.website_settings.title_prefix){wn.title_prefix=wn.boot.website_settings.title_prefix;}}else{erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();$('footer').html('');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup();}} $('#startup_div').toggle(false);} @@ -1082,6 +1085,7 @@ $c_page('home','event_updates','get_unread_messages',null,function(r,rt){if(!r.e if(circle){if(r.message.length){circle.find('span:first').text(r.message.length);circle.toggle(true);}else{circle.toggle(false);}}}else{clearInterval(wn.updates.id);}});} erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);} wn.updates.id=setInterval(update_messages,60000);} +erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat !important;}',{src:src}))} $(document).bind('startup',function(){erpnext.startup.start();}); /* * erpnext/website/js/topbar.js diff --git a/version.num b/version.num index d6ee760bad..988e00fe6b 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -762 \ No newline at end of file +768 \ No newline at end of file From fd5a2138905ac841f4c8593889db8366446e448a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 29 Feb 2012 18:58:02 +0530 Subject: [PATCH 14/81] fix in account setup and user addition --- erpnext/setup/doctype/setup_control/setup_control.py | 11 +++++++---- erpnext/utilities/page/users/users.py | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/erpnext/setup/doctype/setup_control/setup_control.py b/erpnext/setup/doctype/setup_control/setup_control.py index 708b32ac5a..6b8b37c236 100644 --- a/erpnext/setup/doctype/setup_control/setup_control.py +++ b/erpnext/setup/doctype/setup_control/setup_control.py @@ -48,8 +48,8 @@ class DocType: args = json.loads(args) self.set_cp_defaults(args['company'], args['industry'], args['time_zone'], args['country'], args['account_name']) - self.create_profile(args['user'], args['first_name'], args['last_name'], args.get('pwd')) - + self.create_profile(args['user'], args['first_name'], args['last_name'], args.get('pwd')) + # Domain related updates try: from server_tools.gateway_utils import add_domain_map @@ -58,7 +58,9 @@ class DocType: pass # add record in domain_list of Website Settings - webnotes.conn.set_value('Website Settings', 'Website Settings', 'subdomain', args['url_name'] + ".erpnext.com") + account_url = args['url_name'] + '.erpnext.com' + webnotes.conn.set_value('Website Settings', 'Website Settings', + 'subdomain', account_url) # Account Setup @@ -125,7 +127,8 @@ class DocType: """update activty feed and create todo for creation of item, customer, vendor""" import home home.make_feed('Comment', 'ToDo Item', '', webnotes.session['user'], - '"' + 'Setup Complete. Please check your To Do List' + '"', '#6B24B3') + '"' + 'Setup Complete. Please check your \ + To Do List' + '"', '#6B24B3') d = Document('ToDo Item') d.description = 'Create your first Customer' diff --git a/erpnext/utilities/page/users/users.py b/erpnext/utilities/page/users/users.py index 44e2fb2aac..bf8cf458a6 100644 --- a/erpnext/utilities/page/users/users.py +++ b/erpnext/utilities/page/users/users.py @@ -154,7 +154,8 @@ def send_welcome_mail(email, args): args.update({ 'company': webnotes.conn.get_default('company'), 'password': args.get('password'), - 'account_url': webnotes.conn.get_default('account_url') + 'account_url': webnotes.conn.get_value('Website Settings', 'Website + Settings', 'subdomain') or "" }) if not args.get('last_name'): args['last_name'] = '' sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args, from_defs=1) @@ -189,4 +190,4 @@ password: %(password)s To login to your new ERPNext account, please go to: %(account_url)s -""" \ No newline at end of file +""" From 9a6399669946fedbfdf202001f67719b5a797a6a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 29 Feb 2012 18:59:45 +0530 Subject: [PATCH 15/81] fix in account setup and user addition --- erpnext/utilities/page/users/users.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/utilities/page/users/users.py b/erpnext/utilities/page/users/users.py index bf8cf458a6..ca482137ef 100644 --- a/erpnext/utilities/page/users/users.py +++ b/erpnext/utilities/page/users/users.py @@ -154,8 +154,8 @@ def send_welcome_mail(email, args): args.update({ 'company': webnotes.conn.get_default('company'), 'password': args.get('password'), - 'account_url': webnotes.conn.get_value('Website Settings', 'Website - Settings', 'subdomain') or "" + 'account_url': webnotes.conn.get_value('Website Settings', + 'Website Settings', 'subdomain') or "" }) if not args.get('last_name'): args['last_name'] = '' sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args, from_defs=1) From 204e77d125b98b33cdeaa59434354dd25678d01f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 29 Feb 2012 19:09:20 +0530 Subject: [PATCH 16/81] background, user_info --- build.json | 1 + erpnext/home/page/activity/activity.js | 2 +- erpnext/startup/js/complete_setup.js | 2 +- erpnext/utilities/page/messages/messages.js | 6 +++--- erpnext/utilities/page/users/users.js | 3 ++- js/all-app.js | 11 ++++++++++- js/all-web.js | 11 ++++++++++- version.num | 2 +- 8 files changed, 29 insertions(+), 9 deletions(-) diff --git a/build.json b/build.json index 76f3da0304..17d38b3141 100644 --- a/build.json +++ b/build.json @@ -9,6 +9,7 @@ "lib/js/wn/require.js", "lib/js/wn/dom.js", "lib/js/wn/page.js", + "lib/js/wn/misc/user.js", "lib/js/lib/json2.js", "lib/js/core.js" ] diff --git a/erpnext/home/page/activity/activity.js b/erpnext/home/page/activity/activity.js index d72c7aeab4..7dbf476acf 100644 --- a/erpnext/home/page/activity/activity.js +++ b/erpnext/home/page/activity/activity.js @@ -19,7 +19,7 @@ erpnext.ActivityFeed = Class.extend({ %(link)s %(subject)s ', data)); }, scrub_data: function(data) { - data.by = wn.boot.user_fullnames[data.owner]; + data.by = wn.user_info(data.owner).fullname; // feedtype if(!data.feed_type) { diff --git a/erpnext/startup/js/complete_setup.js b/erpnext/startup/js/complete_setup.js index 26b2d3b689..ac89affa5c 100644 --- a/erpnext/startup/js/complete_setup.js +++ b/erpnext/startup/js/complete_setup.js @@ -82,7 +82,7 @@ erpnext.complete_setup = function() { $c_obj('Setup Control','setup_account',data,function(r, rt){ sys_defaults = r.message; user_fullname = r.message.user_fullname; - wn.boot.user_fullnames[user] = user_fullname; + wn.boot.user_info[user].fullname = user_fullname; d.hide(); $('header').toggle(true); page_body.wntoolbar.set_user_name(); diff --git a/erpnext/utilities/page/messages/messages.js b/erpnext/utilities/page/messages/messages.js index 43adce404d..f33c47b99d 100644 --- a/erpnext/utilities/page/messages/messages.js +++ b/erpnext/utilities/page/messages/messages.js @@ -65,7 +65,7 @@ erpnext.messages = { $(wn.pages.messages).find('.well').toggle(contact==user ? false : true); $(wn.pages.messages).find('h1:first').html('Messages: ' - + (user==contact ? 'From everyone' : wn.boot.user_fullnames[contact])) + + (user==contact ? 'From everyone' : wn.user_info(contact).fullname)); erpnext.messages.contact = contact; erpnext.messages.list.opts.args.contact = contact; @@ -98,7 +98,7 @@ erpnext.messages = { }, render_row: function(wrapper, data) { data.creation = dateutil.comment_when(data.creation); - data.comment_by_fullname = wn.boot.user_fullnames[data.owner]; + data.comment_by_fullname = wn.user_info(data.owner).fullname; data.reply_html = ''; if(data.owner==user) { @@ -143,7 +143,7 @@ erpnext.messages = { var $body = $(wn.pages.messages).find('.section-body'); for(var i in r.message) { var p = r.message[i]; - p.fullname = wn.boot.user_fullnames[p.name]; + p.fullname = wn.user_info(p.name).fullname; p.name = p.name.replace('@', '__at__'); $body.append(repl('', p)) diff --git a/erpnext/utilities/page/users/users.js b/erpnext/utilities/page/users/users.js index 76f5672eeb..d1c916c6fd 100644 --- a/erpnext/utilities/page/users/users.js +++ b/erpnext/utilities/page/users/users.js @@ -70,7 +70,7 @@ $.extend(wn.pages.users, { } else { data.imgsrc = 'lib/images/ui/no_img_' + (data.gender=='Female' ? 'f' : 'm') + '.gif'; } - data.fullname = wn.boot.user_fullnames[data.name]; + data.fullname = wn.user_info(data.name).fullname; data.delete_html = ''; if(!data.enabled) data.delete_html = '×'; @@ -232,6 +232,7 @@ $.extend(wn.pages.users, { $c_page('utilities', 'users', 'add_user', v, function(r,rt) { if(r.exc) { msgprint(r.exc); return; } else { + wn.boot.user_info[v.user] = {fullname:v.first_name + ' ' + v.last_name}; d.hide(); me.refresh(); } diff --git a/js/all-app.js b/js/all-app.js index e5e796783e..fafaec294b 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -201,6 +201,15 @@ wn.page={set:function(src){var new_selection=$('.inner div.content[_src="'+src+' $('.inner .current_page').removeClass('current_page');new_selection.addClass('current_page');var title=$('nav ul li a[href*="'+src+'"]').attr('title')||'No Title' state=window.location.hash;if(state!=src){window.location.hash=state;} else{document.title=title;}}} +/* + * lib/js/wn/misc/user.js + */ +wn.user_info=function(uid){var def={'fullname':uid,'image':'lib/images/ui/no_img_m.gif'} +if(!wn.boot.user_info)return def +if(!wn.boot.user_info[uid])return def +if(!wn.boot.user_info[uid].fullname) +wn.boot.user_info[uid].fullname=uid;if(!wn.boot.user_info[uid].image) +wn.boot.user_info[uid].image=def.image;return wn.boot.user_info[uid];} /* * lib/js/lib/json2.js */ @@ -2180,7 +2189,7 @@ me.dialog.clear();me.dialog.show();}}); /* * lib/js/legacy/app.js */ -var popup_cont;var session={};var start_sid=null;if(!wn)var wn={};function startup(){start_sid=get_cookie('sid');popup_cont=$a(document.getElementsByTagName('body')[0],'div');var setup_globals=function(r){wn.boot=r;profile=r.profile;user=r.profile.name;user_fullname=wn.boot.user_fullnames?wn.boot.user_fullnames[user]:'Guest';user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;home_page=r.home_page;_p.letter_heads=r.letter_heads;sys_defaults=r.sysdefaults;session.rt=profile.can_read;if(r.ipinfo)session.ipinfo=r.ipinfo;session.dt_labels=r.dt_labels;session.rev_dt_labels={} +var popup_cont;var session={};var start_sid=null;if(!wn)var wn={};function startup(){start_sid=get_cookie('sid');popup_cont=$a(document.getElementsByTagName('body')[0],'div');var setup_globals=function(r){wn.boot=r;profile=r.profile;user=r.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;home_page=r.home_page;_p.letter_heads=r.letter_heads;sys_defaults=r.sysdefaults;session.rt=profile.can_read;if(r.ipinfo)session.ipinfo=r.ipinfo;session.dt_labels=r.dt_labels;session.rev_dt_labels={} if(r.dt_labels){for(key in r.dt_labels)session.rev_dt_labels[r.dt_labels[key]]=key;} wn.control_panel=r.control_panel;} var setup_history=function(r){rename_observers.push(nav_obj);} diff --git a/js/all-web.js b/js/all-web.js index 1df96396ca..5137d58b60 100644 --- a/js/all-web.js +++ b/js/all-web.js @@ -127,6 +127,15 @@ wn.page={set:function(src){var new_selection=$('.inner div.content[_src="'+src+' $('.inner .current_page').removeClass('current_page');new_selection.addClass('current_page');var title=$('nav ul li a[href*="'+src+'"]').attr('title')||'No Title' state=window.location.hash;if(state!=src){window.location.hash=state;} else{document.title=title;}}} +/* + * lib/js/wn/misc/user.js + */ +wn.user_info=function(uid){var def={'fullname':uid,'image':'lib/images/ui/no_img_m.gif'} +if(!wn.boot.user_info)return def +if(!wn.boot.user_info[uid])return def +if(!wn.boot.user_info[uid].fullname) +wn.boot.user_info[uid].fullname=uid;if(!wn.boot.user_info[uid].image) +wn.boot.user_info[uid].image=def.image;return wn.boot.user_info[uid];} /* * lib/js/lib/json2.js */ @@ -1028,7 +1037,7 @@ this.setup();} /* * lib/js/legacy/app.js */ -var popup_cont;var session={};var start_sid=null;if(!wn)var wn={};function startup(){start_sid=get_cookie('sid');popup_cont=$a(document.getElementsByTagName('body')[0],'div');var setup_globals=function(r){wn.boot=r;profile=r.profile;user=r.profile.name;user_fullname=wn.boot.user_fullnames?wn.boot.user_fullnames[user]:'Guest';user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;home_page=r.home_page;_p.letter_heads=r.letter_heads;sys_defaults=r.sysdefaults;session.rt=profile.can_read;if(r.ipinfo)session.ipinfo=r.ipinfo;session.dt_labels=r.dt_labels;session.rev_dt_labels={} +var popup_cont;var session={};var start_sid=null;if(!wn)var wn={};function startup(){start_sid=get_cookie('sid');popup_cont=$a(document.getElementsByTagName('body')[0],'div');var setup_globals=function(r){wn.boot=r;profile=r.profile;user=r.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;home_page=r.home_page;_p.letter_heads=r.letter_heads;sys_defaults=r.sysdefaults;session.rt=profile.can_read;if(r.ipinfo)session.ipinfo=r.ipinfo;session.dt_labels=r.dt_labels;session.rev_dt_labels={} if(r.dt_labels){for(key in r.dt_labels)session.rev_dt_labels[r.dt_labels[key]]=key;} wn.control_panel=r.control_panel;} var setup_history=function(r){rename_observers.push(nav_obj);} diff --git a/version.num b/version.num index c1891366fd..eb6fa5affc 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -769 \ No newline at end of file +773 \ No newline at end of file From a4f454faa04927f7d1e9b5ec4af6337aa2cbfc9a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 29 Feb 2012 19:19:01 +0530 Subject: [PATCH 17/81] module page link fix --- erpnext/startup/js/modules.js | 5 ++++- erpnext/stock/page/stock_home/stock_home.html | 2 +- erpnext/website/page/website_home/website_home.html | 2 +- js/all-app.js | 4 ++-- js/all-web.js | 2 +- version.num | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/erpnext/startup/js/modules.js b/erpnext/startup/js/modules.js index dbd11b0b39..add068c75f 100644 --- a/erpnext/startup/js/modules.js +++ b/erpnext/startup/js/modules.js @@ -73,7 +73,10 @@ erpnext.module_page.make_list = function(module, wrapper) { args: { module: module }, - no_refresh: true + no_refresh: true, + callback: function(r) { + erpnext.module_page.hide_links(wrapper) + } }); wrapper.list.run(); } \ No newline at end of file diff --git a/erpnext/stock/page/stock_home/stock_home.html b/erpnext/stock/page/stock_home/stock_home.html index 9ba21a43dd..bab93dcfbd 100644 --- a/erpnext/stock/page/stock_home/stock_home.html +++ b/erpnext/stock/page/stock_home/stock_home.html @@ -4,7 +4,7 @@

    Stock


    -

    Stock Entry

    +

    Stock Entry

    Transfer stock from one warehouse to another

    Delivery Note

    Delivery (shipment) to customers

    diff --git a/erpnext/website/page/website_home/website_home.html b/erpnext/website/page/website_home/website_home.html index 747ca5aa03..4c3c9c6c7b 100644 --- a/erpnext/website/page/website_home/website_home.html +++ b/erpnext/website/page/website_home/website_home.html @@ -4,7 +4,7 @@

    Support


    -

    Web Page

    +

    Web Page

    Static (content) web page

    Product

    Product listed in catolog

    diff --git a/js/all-app.js b/js/all-app.js index fafaec294b..be01071a0b 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -901,7 +901,7 @@ this.clear=function(){this.results_area.innerHTML='';this.table=null;$ds(this.re this.make_results=function(r,rt){if(this.start==0)this.clear();$dh(this.more_button_area);if(this.loading_img)$dh(this.loading_img) if(r.message)r.values=r.message;if(r.values&&r.values.length){this.values=r.values;var m=Math.min(r.values.length,this.page_length);for(var i=0;i=this.page_length)$ds(this.more_button_area);}else{if(this.start==0){$dh(this.results_area);$ds(this.no_results_area);}} -if(this.onrun)this.onrun();if(this.opts.onrun)this.opts.onrun();} +if(this.onrun)this.onrun();if(this.opts.onrun)this.opts.onrun();if(this.opts.callback)this.opts.callback(r);} this.add_row=function(){return $a(this.results_area,'div','',(opts.cell_style?opts.cell_style:{padding:'3px 0px'}));} this.run=function(callback,append){if(callback) this.onrun=callback;if(!append) @@ -2255,7 +2255,7 @@ wn.provide('erpnext.module_page');erpnext.module_page.setup_page=function(module erpnext.module_page.hide_links=function(wrapper){$(wrapper).find('[href*="List/"]').each(function(){var href=$(this).attr('href');var dt=href.split('/')[1];if(wn.boot.profile.can_read.indexOf(get_label_doctype(dt))==-1){var txt=$(this).text();$(this).parent().css('color','#999').html(txt);}});$(wrapper).find('[data-doctype]').each(function(){var dt=$(this).attr('data-doctype');if(wn.boot.profile.can_read.indexOf(dt)==-1){var txt=$(this).text();$(this).parent().css('color','#999').html(txt);}});$(wrapper).find('[href*="Form/"]').each(function(){var href=$(this).attr('href');var dt=href.split('/')[1];if(wn.boot.profile.can_read.indexOf(get_label_doctype(dt))==-1){var txt=$(this).text();$(this).parent().css('color','#999').html(txt);}});} erpnext.module_page.make_list=function(module,wrapper){wrapper.list=new wn.widgets.Listing({parent:$(wrapper).find('.reports-list').get(0),method:'utilities.get_report_list',render_row:function(row,data){if(!data.parent_doc_type)data.parent_doc_type=data.doc_type;$(row).html(repl('\ - %(criteria_name)s',data))},args:{module:module},no_refresh:true});wrapper.list.run();} + %(criteria_name)s',data))},args:{module:module},no_refresh:true,callback:function(r){erpnext.module_page.hide_links(wrapper)}});wrapper.list.run();} /* * erpnext/startup/js/toolbar.js */ diff --git a/js/all-web.js b/js/all-web.js index 5137d58b60..cad3c77fd3 100644 --- a/js/all-web.js +++ b/js/all-web.js @@ -716,7 +716,7 @@ this.clear=function(){this.results_area.innerHTML='';this.table=null;$ds(this.re this.make_results=function(r,rt){if(this.start==0)this.clear();$dh(this.more_button_area);if(this.loading_img)$dh(this.loading_img) if(r.message)r.values=r.message;if(r.values&&r.values.length){this.values=r.values;var m=Math.min(r.values.length,this.page_length);for(var i=0;i=this.page_length)$ds(this.more_button_area);}else{if(this.start==0){$dh(this.results_area);$ds(this.no_results_area);}} -if(this.onrun)this.onrun();if(this.opts.onrun)this.opts.onrun();} +if(this.onrun)this.onrun();if(this.opts.onrun)this.opts.onrun();if(this.opts.callback)this.opts.callback(r);} this.add_row=function(){return $a(this.results_area,'div','',(opts.cell_style?opts.cell_style:{padding:'3px 0px'}));} this.run=function(callback,append){if(callback) this.onrun=callback;if(!append) diff --git a/version.num b/version.num index eb6fa5affc..fc0b67d079 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -773 \ No newline at end of file +774 \ No newline at end of file From 63b275c97f74e9590027535e13c1f8a75e75c2bf Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 1 Mar 2012 10:35:35 +0530 Subject: [PATCH 18/81] allowed debit and credit against same acc head --- erpnext/accounts/doctype/gl_entry/gl_entry.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index c45e1625ac..3892007bb4 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -36,10 +36,12 @@ class DocType: msgprint("GL Entry: Debit or Credit amount is mandatory for %s" % self.doc.account) raise Exception + + # COMMMENTED below to allow zero amount (+ and -) entry in tax table # Debit and credit can not done at the same time - if flt(self.doc.credit) != 0 and flt(self.doc.debit) != 0: - msgprint("Sorry you cannot credit and debit under same account head.") - raise Exception, "Validation Error." + #if flt(self.doc.credit) != 0 and flt(self.doc.debit) != 0: + # msgprint("Sorry you cannot credit and debit under same account head.") + # raise Exception, "Validation Error." # Cost center is required only if transaction made against pl account #-------------------------------------------------------------------- From 177ca8dbbd96349b5e490cb3d1d58aa71d92340d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 1 Mar 2012 10:54:34 +0530 Subject: [PATCH 19/81] Description changed --- erpnext/selling/doctype/customer/customer.txt | 447 +++++++++--------- 1 file changed, 211 insertions(+), 236 deletions(-) diff --git a/erpnext/selling/doctype/customer/customer.txt b/erpnext/selling/doctype/customer/customer.txt index 24271ee688..346b4d1029 100644 --- a/erpnext/selling/doctype/customer/customer.txt +++ b/erpnext/selling/doctype/customer/customer.txt @@ -5,47 +5,48 @@ { 'creation': '2010-08-08 17:08:56', 'docstatus': 0, - 'modified': '2011-07-20 10:42:05', - 'modified_by': 'Administrator', - 'owner': 'Administrator' + 'modified': '2012-02-29 13:24:31', + 'modified_by': u'Administrator', + 'owner': u'Administrator' }, # These values are common for all DocType { - '_last_update': '1309508837', + '_last_update': u'1330501485', 'allow_print': 0, 'allow_trash': 1, - 'colour': 'White:FFF', + 'colour': u'White:FFF', + 'default_print_format': u'Standard', 'doctype': 'DocType', - 'document_type': 'Master', - 'module': 'Selling', + 'document_type': u'Master', + 'module': u'Selling', 'name': '__common__', - 'search_fields': 'customer_name,customer_group,country,territory', - 'section_style': 'Tabbed', - 'server_code_error': ' ', + 'search_fields': u'customer_name,customer_group,country,territory', + 'section_style': u'Tabbed', + 'server_code_error': u' ', 'show_in_menu': 0, - 'subject': "eval:'%(customer_name)s'=='%(name)s' ? ' ' : '%(customer_name)s'", - 'tag_fields': 'customer_group,customer_type', - 'version': 433 + 'subject': u'eval:"%(customer_name)s"=="%(name)s" ? "" : "%(customer_name)s"', + 'tag_fields': u'customer_group,customer_type', + 'version': 434 }, # These values are common for all DocField { - 'doctype': 'DocField', + 'doctype': u'DocField', 'name': '__common__', - 'parent': 'Customer', - 'parentfield': 'fields', - 'parenttype': 'DocType' + 'parent': u'Customer', + 'parentfield': u'fields', + 'parenttype': u'DocType' }, # These values are common for all DocPerm { 'amend': 0, - 'doctype': 'DocPerm', + 'doctype': u'DocPerm', 'name': '__common__', - 'parent': 'Customer', - 'parentfield': 'permissions', - 'parenttype': 'DocType', + 'parent': u'Customer', + 'parentfield': u'permissions', + 'parenttype': u'DocType', 'read': 1, 'submit': 0 }, @@ -53,17 +54,16 @@ # DocType, Customer { 'doctype': 'DocType', - 'name': 'Customer' + 'name': u'Customer' }, # DocPerm { 'cancel': 0, 'create': 0, - 'doctype': 'DocPerm', - 'idx': 1, + 'doctype': u'DocPerm', 'permlevel': 1, - 'role': 'Sales Manager', + 'role': u'Sales Manager', 'write': 0 }, @@ -71,10 +71,9 @@ { 'cancel': 0, 'create': 0, - 'doctype': 'DocPerm', - 'idx': 2, + 'doctype': u'DocPerm', 'permlevel': 0, - 'role': 'Sales Manager', + 'role': u'Sales Manager', 'write': 0 }, @@ -82,10 +81,9 @@ { 'cancel': 0, 'create': 0, - 'doctype': 'DocPerm', - 'idx': 3, + 'doctype': u'DocPerm', 'permlevel': 1, - 'role': 'Sales User', + 'role': u'Sales User', 'write': 0 }, @@ -93,10 +91,9 @@ { 'cancel': 0, 'create': 0, - 'doctype': 'DocPerm', - 'idx': 4, + 'doctype': u'DocPerm', 'permlevel': 0, - 'role': 'Sales User', + 'role': u'Sales User', 'write': 0 }, @@ -104,10 +101,9 @@ { 'cancel': 1, 'create': 1, - 'doctype': 'DocPerm', - 'idx': 5, + 'doctype': u'DocPerm', 'permlevel': 0, - 'role': 'Sales Master Manager', + 'role': u'Sales Master Manager', 'write': 1 }, @@ -115,38 +111,35 @@ { 'cancel': 0, 'create': 0, - 'doctype': 'DocPerm', - 'idx': 6, + 'doctype': u'DocPerm', 'permlevel': 1, - 'role': 'Sales Master Manager', + 'role': u'Sales Master Manager', 'write': 0 }, # DocField { - 'colour': 'White:FFF', - 'description': 'Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts', - 'doctype': 'DocField', - 'fieldtype': 'Section Break', - 'idx': 1, - 'label': 'Basic Info', - 'oldfieldtype': 'Section Break', + 'colour': u'White:FFF', + 'description': u'Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts', + 'doctype': u'DocField', + 'fieldtype': u'Section Break', + 'label': u'Basic Info', + 'oldfieldtype': u'Section Break', 'permlevel': 0, 'reqd': 0 }, # DocField { - 'doctype': 'DocField', - 'fieldname': 'customer_name', - 'fieldtype': 'Data', + 'doctype': u'DocField', + 'fieldname': u'customer_name', + 'fieldtype': u'Data', 'hidden': 0, - 'idx': 2, 'in_filter': 1, - 'label': 'Customer Name', + 'label': u'Customer Name', 'no_copy': 1, - 'oldfieldname': 'customer_name', - 'oldfieldtype': 'Data', + 'oldfieldname': u'customer_name', + 'oldfieldtype': u'Data', 'permlevel': 0, 'print_hide': 0, 'report_hide': 0, @@ -156,330 +149,312 @@ # DocField { - 'doctype': 'DocField', - 'fieldname': 'customer_type', - 'fieldtype': 'Select', - 'idx': 3, - 'label': 'Customer Type', - 'oldfieldname': 'customer_type', - 'oldfieldtype': 'Select', - 'options': '\nCompany\nIndividual', + 'doctype': u'DocField', + 'fieldname': u'customer_type', + 'fieldtype': u'Select', + 'label': u'Customer Type', + 'oldfieldname': u'customer_type', + 'oldfieldtype': u'Select', + 'options': u'\nCompany\nIndividual', 'permlevel': 0, 'reqd': 1 }, # DocField { - 'doctype': 'DocField', - 'fieldname': 'naming_series', - 'fieldtype': 'Select', - 'idx': 4, - 'label': 'Series', + 'doctype': u'DocField', + 'fieldname': u'naming_series', + 'fieldtype': u'Select', + 'label': u'Series', 'no_copy': 1, - 'options': '\nCUST\nCUSTMUM\nCUSTOM', + 'options': u'\nCUST\nCUSTMUM', 'permlevel': 0, 'print_hide': 0 }, # DocField { - 'colour': 'White:FFF', - 'description': 'Fetch lead which will be converted into customer.', - 'doctype': 'DocField', - 'fieldname': 'lead_name', - 'fieldtype': 'Link', + 'colour': u'White:FFF', + 'description': u'Fetch lead which will be converted into customer.', + 'doctype': u'DocField', + 'fieldname': u'lead_name', + 'fieldtype': u'Link', 'hidden': 0, - 'idx': 5, 'in_filter': 1, - 'label': 'Lead Ref', + 'label': u'Lead Ref', 'no_copy': 1, - 'oldfieldname': 'lead_name', - 'oldfieldtype': 'Link', - 'options': 'Lead', + 'oldfieldname': u'lead_name', + 'oldfieldtype': u'Link', + 'options': u'Lead', 'permlevel': 0, 'print_hide': 1, 'report_hide': 1, - 'trigger': 'Client' + 'trigger': u'Client' }, # DocField { - 'doctype': 'DocField', - 'fieldtype': 'Column Break', - 'idx': 6, + 'doctype': u'DocField', + 'fieldtype': u'Column Break', 'permlevel': 0, - 'width': '50%' + 'width': u'50%' }, # DocField { - 'colour': 'White:FFF', - 'description': 'To manage Customer Groups, click here', - 'doctype': 'DocField', - 'fieldname': 'customer_group', - 'fieldtype': 'Link', + 'colour': u'White:FFF', + 'description': u'To manage Customer Groups, click here', + 'doctype': u'DocField', + 'fieldname': u'customer_group', + 'fieldtype': u'Link', 'hidden': 0, - 'idx': 7, 'in_filter': 1, - 'label': 'Customer Group', - 'oldfieldname': 'customer_group', - 'oldfieldtype': 'Link', - 'options': 'Customer Group', + 'label': u'Customer Group', + 'oldfieldname': u'customer_group', + 'oldfieldtype': u'Link', + 'options': u'Customer Group', 'permlevel': 0, 'print_hide': 0, 'reqd': 1, 'search_index': 1, - 'trigger': 'Client' + 'trigger': u'Client' }, # DocField { - 'colour': 'White:FFF', - 'description': 'To manage Territory, click here', - 'doctype': 'DocField', - 'fieldname': 'territory', - 'fieldtype': 'Link', - 'idx': 8, - 'label': 'Territory', - 'oldfieldname': 'territory', - 'oldfieldtype': 'Link', - 'options': 'Territory', + 'colour': u'White:FFF', + 'description': u'To manage Territory, click here', + 'doctype': u'DocField', + 'fieldname': u'territory', + 'fieldtype': u'Link', + 'label': u'Territory', + 'oldfieldname': u'territory', + 'oldfieldtype': u'Link', + 'options': u'Territory', 'permlevel': 0, 'print_hide': 1, 'reqd': 1, - 'trigger': 'Client' + 'trigger': u'Client' }, # DocField { - 'colour': 'White:FFF', - 'doctype': 'DocField', - 'fieldtype': 'Section Break', - 'idx': 9, - 'label': 'Address & Contacts', + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldtype': u'Section Break', + 'label': u'Address & Contacts', 'permlevel': 0 }, # DocField { - 'colour': 'White:FFF', - 'depends_on': 'eval:doc.__islocal', - 'doctype': 'DocField', - 'fieldtype': 'HTML', - 'idx': 10, - 'label': 'Address Desc', - 'options': 'Addresses will appear only when you save the customer', + 'colour': u'White:FFF', + 'depends_on': u'eval:doc.__islocal', + 'doctype': u'DocField', + 'fieldtype': u'HTML', + 'label': u'Address Desc', + 'options': u'Addresses will appear only when you save the customer', 'permlevel': 0 }, # DocField { - 'colour': 'White:FFF', - 'doctype': 'DocField', - 'fieldtype': 'HTML', - 'idx': 11, - 'label': 'Address HTML', + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldtype': u'HTML', + 'label': u'Address HTML', 'permlevel': 1 }, # DocField { - 'doctype': 'DocField', - 'fieldtype': 'Column Break', - 'idx': 12, + 'doctype': u'DocField', + 'fieldtype': u'Column Break', 'permlevel': 0, - 'width': '50%' + 'width': u'50%' }, # DocField { - 'colour': 'White:FFF', - 'depends_on': 'eval:doc.__islocal', - 'doctype': 'DocField', - 'fieldtype': 'HTML', - 'idx': 13, - 'label': 'Contact Desc', - 'options': 'Contact Details will appear only when you save the customer', + 'colour': u'White:FFF', + 'depends_on': u'eval:doc.__islocal', + 'doctype': u'DocField', + 'fieldtype': u'HTML', + 'label': u'Contact Desc', + 'options': u'Contact Details will appear only when you save the customer', 'permlevel': 0 }, # DocField { - 'colour': 'White:FFF', - 'doctype': 'DocField', - 'fieldtype': 'HTML', - 'idx': 14, - 'label': 'Contact HTML', - 'oldfieldtype': 'HTML', + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldtype': u'HTML', + 'label': u'Contact HTML', + 'oldfieldtype': u'HTML', 'permlevel': 1 }, # DocField { - 'colour': 'White:FFF', - 'doctype': 'DocField', - 'fieldtype': 'Section Break', - 'idx': 15, - 'label': 'More Info', - 'oldfieldtype': 'Section Break', + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldtype': u'Section Break', + 'label': u'More Info', + 'oldfieldtype': u'Section Break', 'permlevel': 0 }, # DocField { - 'colour': 'White:FFF', - 'description': 'To create an Account Head under a different company, then set the company and click the button below.', - 'doctype': 'DocField', - 'fieldname': 'company', - 'fieldtype': 'Link', - 'idx': 16, + 'doctype': u'DocField', + 'fieldtype': u'Column Break', + 'permlevel': 0, + 'width': u'50%' + }, + + # DocField + { + 'colour': u'White:FFF', + 'description': u'To create an Account Head under a different company, select the company and save customer.', + 'doctype': u'DocField', + 'fieldname': u'company', + 'fieldtype': u'Link', 'in_filter': 1, - 'label': 'Company', - 'oldfieldname': 'company', - 'oldfieldtype': 'Link', - 'options': 'Company', + 'label': u'Company', + 'oldfieldname': u'company', + 'oldfieldtype': u'Link', + 'options': u'Company', 'permlevel': 0, 'reqd': 1, - 'search_index': 0 + 'search_index': 1 }, # DocField { - 'colour': 'White:FFF', - 'description': "Your Customer's TAX registration numbers (if applicable) or any general information", - 'doctype': 'DocField', - 'fieldname': 'customer_details', - 'fieldtype': 'Text', - 'idx': 17, - 'label': 'Customer Details', - 'oldfieldname': 'customer_details', - 'oldfieldtype': 'Code', + 'colour': u'White:FFF', + 'description': u"Your Customer's TAX registration numbers (if applicable) or any general information", + 'doctype': u'DocField', + 'fieldname': u'customer_details', + 'fieldtype': u'Text', + 'label': u'Customer Details', + 'oldfieldname': u'customer_details', + 'oldfieldtype': u'Code', 'permlevel': 0 }, # DocField { - 'doctype': 'DocField', - 'fieldtype': 'Column Break', - 'idx': 18, + 'doctype': u'DocField', + 'fieldtype': u'Column Break', 'permlevel': 0, - 'width': '50%' + 'width': u'50%' }, # DocField { - 'doctype': 'DocField', - 'fieldname': 'credit_days', - 'fieldtype': 'Int', - 'idx': 19, - 'label': 'Credit Days', - 'oldfieldname': 'credit_days', - 'oldfieldtype': 'Int', + 'doctype': u'DocField', + 'fieldname': u'credit_days', + 'fieldtype': u'Int', + 'label': u'Credit Days', + 'oldfieldname': u'credit_days', + 'oldfieldtype': u'Int', 'permlevel': 0 }, # DocField { - 'doctype': 'DocField', - 'fieldname': 'credit_limit', - 'fieldtype': 'Currency', - 'idx': 20, - 'label': 'Credit Limit', - 'oldfieldname': 'credit_limit', - 'oldfieldtype': 'Currency', + 'doctype': u'DocField', + 'fieldname': u'credit_limit', + 'fieldtype': u'Currency', + 'label': u'Credit Limit', + 'oldfieldname': u'credit_limit', + 'oldfieldtype': u'Currency', 'permlevel': 0 }, # DocField { - 'doctype': 'DocField', - 'fieldname': 'website', - 'fieldtype': 'Data', - 'idx': 21, - 'label': 'Website', + 'doctype': u'DocField', + 'fieldname': u'website', + 'fieldtype': u'Data', + 'label': u'Website', 'permlevel': 0 }, # DocField { - 'doctype': 'DocField', - 'fieldtype': 'Section Break', - 'idx': 22, - 'label': 'Sales Team', - 'oldfieldtype': 'Section Break', + 'doctype': u'DocField', + 'fieldtype': u'Section Break', + 'label': u'Sales Team', + 'oldfieldtype': u'Section Break', 'permlevel': 0 }, # DocField { - 'doctype': 'DocField', - 'fieldname': 'default_sales_partner', - 'fieldtype': 'Link', - 'idx': 23, - 'label': 'Default Sales Partner', - 'oldfieldname': 'default_sales_partner', - 'oldfieldtype': 'Link', - 'options': 'Sales Partner', + 'doctype': u'DocField', + 'fieldname': u'default_sales_partner', + 'fieldtype': u'Link', + 'label': u'Default Sales Partner', + 'oldfieldname': u'default_sales_partner', + 'oldfieldtype': u'Link', + 'options': u'Sales Partner', 'permlevel': 0 }, # DocField { - 'doctype': 'DocField', - 'fieldname': 'default_commission_rate', - 'fieldtype': 'Currency', - 'idx': 24, - 'label': 'Default Commission Rate', - 'oldfieldname': 'default_commission_rate', - 'oldfieldtype': 'Currency', + 'doctype': u'DocField', + 'fieldname': u'default_commission_rate', + 'fieldtype': u'Currency', + 'label': u'Default Commission Rate', + 'oldfieldname': u'default_commission_rate', + 'oldfieldtype': u'Currency', 'permlevel': 0 }, # DocField { - 'doctype': 'DocField', - 'fieldname': 'sales_team', - 'fieldtype': 'Table', - 'idx': 25, - 'label': 'Sales Team Details', - 'oldfieldname': 'sales_team', - 'oldfieldtype': 'Table', - 'options': 'Sales Team', + 'doctype': u'DocField', + 'fieldname': u'sales_team', + 'fieldtype': u'Table', + 'label': u'Sales Team Details', + 'oldfieldname': u'sales_team', + 'oldfieldtype': u'Table', + 'options': u'Sales Team', 'permlevel': 0 }, # DocField { - 'colour': 'White:FFF', - 'depends_on': 'eval:!doc.__islocal', - 'doctype': 'DocField', - 'fieldtype': 'Section Break', - 'idx': 26, - 'label': 'Transaction History', + 'colour': u'White:FFF', + 'depends_on': u'eval:!doc.__islocal', + 'doctype': u'DocField', + 'fieldtype': u'Section Break', + 'label': u'Transaction History', 'permlevel': 0 }, # DocField { - 'colour': 'White:FFF', - 'depends_on': 'eval:!doc.__islocal', - 'doctype': 'DocField', - 'fieldtype': 'HTML', - 'idx': 27, - 'label': 'History HTML', + 'colour': u'White:FFF', + 'depends_on': u'eval:!doc.__islocal', + 'doctype': u'DocField', + 'fieldtype': u'HTML', + 'label': u'History HTML', 'permlevel': 0 }, # DocField { - 'colour': 'White:FFF', - 'doctype': 'DocField', - 'fieldname': 'trash_reason', - 'fieldtype': 'Small Text', - 'idx': 28, - 'label': 'Trash Reason', - 'oldfieldname': 'trash_reason', - 'oldfieldtype': 'Small Text', + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'trash_reason', + 'fieldtype': u'Small Text', + 'label': u'Trash Reason', + 'oldfieldname': u'trash_reason', + 'oldfieldtype': u'Small Text', 'permlevel': 1 } ] \ No newline at end of file From 284a07e23b3ea60d42025a9dc62238cdd477fca4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 1 Mar 2012 10:55:41 +0530 Subject: [PATCH 20/81] if more info unchecked, more info in customer, supplier will be visible --- erpnext/startup/feature_setup.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/erpnext/startup/feature_setup.js b/erpnext/startup/feature_setup.js index 8644c1dd84..6a5974a5a8 100644 --- a/erpnext/startup/feature_setup.js +++ b/erpnext/startup/feature_setup.js @@ -149,7 +149,6 @@ pscript.feature_dict = { 'Sales Order': {'fields':['sales_team','Packing List']} }, 'fs_more_info': { - 'Customer': {'fields':['More Info']}, 'Delivery Note': {'fields':['More Info']}, 'Enquiry': {'fields':['More Info']}, 'Indent': {'fields':['More Info']}, @@ -160,8 +159,6 @@ pscript.feature_dict = { 'Quotation': {'fields':['More Info']}, 'Receivable Voucher': {'fields':['More Info']}, 'Sales Order': {'fields':['More Info']}, - 'Serial No': {'fields':['More Info']}, - 'Supplier': {'fields':['More Info']} }, 'fs_quality': { 'Item': {'fields':['Item Inspection Criteria','inspection_required']}, From df78d20fab0e7b600d9917930019b254802f5593 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 1 Mar 2012 10:56:50 +0530 Subject: [PATCH 21/81] is_onload is global now --- js/all-app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/all-app.js b/js/all-app.js index 62d63ce67f..9bd715c226 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -1712,12 +1712,12 @@ nav_obj.show_last_open();return 0;} return 1} _f.Frm.prototype.refresh=function(docname){if(docname){if(this.docname!=docname&&!this.meta.in_dialog&&!this.meta.istable)scroll(0,0);this.docname=docname;} if(!this.meta.istable){cur_frm=this;this.parent.cur_frm=this;} -if(this.docname){if(!this.check_doc_perm())return;if(!this.setup_done)this.setup();this.runclientscript('set_perm',this.doctype,this.docname);this.doc=get_local(this.doctype,this.docname);var is_onload=false;if(!this.opendocs[this.docname]){is_onload=true;this.setnewdoc(this.docname);} +if(this.docname){if(!this.check_doc_perm())return;if(!this.setup_done)this.setup();this.runclientscript('set_perm',this.doctype,this.docname);this.doc=get_local(this.doctype,this.docname);cur_frm.cscript.is_onload=false;if(!this.opendocs[this.docname]){cur_frm.cscript.is_onload=true;this.setnewdoc(this.docname);} if(this.doc.__islocal) this.is_editable[this.docname]=1;this.editable=this.is_editable[this.docname];if(!this.doc.__archived&&(this.editable||(!this.editable&&this.meta.istable))){if(this.print_wrapper){$dh(this.print_wrapper);$ds(this.page_layout.wrapper);} if(!this.meta.istable){this.refresh_header();this.sidebar&&this.sidebar.refresh();} this.runclientscript('refresh');$(document).trigger('form_refresh') -this.refresh_tabs();this.refresh_fields();this.refresh_dependency();this.refresh_footer();if(this.layout)this.layout.show();if(is_onload) +this.refresh_tabs();this.refresh_fields();this.refresh_dependency();this.refresh_footer();if(this.layout)this.layout.show();if(cur_frm.cscript.is_onload) this.runclientscript('onload_post_render',this.doctype,this.docname);}else{this.refresh_header();if(this.print_wrapper){this.refresh_print_layout();} this.runclientscript('edit_status_changed');} if(!this.display)this.show_the_frm();if(!this.meta.in_dialog)page_body.change_to('Forms');$(cur_frm.wrapper).trigger('render_complete');}} @@ -2254,7 +2254,7 @@ if(user_roles.indexOf("System Manager")!=-1){$('.navbar .modules').append('
  • Date: Thu, 1 Mar 2012 10:57:23 +0530 Subject: [PATCH 22/81] form cleanup: fixed callback issues --- css/all-app.css | 2 +- css/all-web.css | 2 +- .../receivable_voucher/receivable_voucher.js | 49 +++++++------ .../receivable_voucher/receivable_voucher.py | 19 ++--- .../selling/doctype/quotation/quotation.js | 12 ++-- .../selling/doctype/quotation/quotation.py | 13 ++-- .../doctype/sales_common/sales_common.js | 72 +++++++++---------- .../doctype/sales_common/sales_common.py | 26 +++---- .../doctype/sales_order/sales_order.js | 17 +++-- .../doctype/sales_order/sales_order.py | 15 ++-- .../doctype/delivery_note/delivery_note.js | 12 ++-- .../doctype/delivery_note/delivery_note.py | 15 ++-- version.num | 2 +- 13 files changed, 121 insertions(+), 135 deletions(-) diff --git a/css/all-app.css b/css/all-app.css index b49caedee9..b2fd2e5732 100644 --- a/css/all-app.css +++ b/css/all-app.css @@ -1043,7 +1043,7 @@ div.dialog_head { } div.dialog_body { - padding: 8px 8px 16px; + padding: 8px 4px 16px 4px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; diff --git a/css/all-web.css b/css/all-web.css index bebfe9a334..9359de898e 100644 --- a/css/all-web.css +++ b/css/all-web.css @@ -362,7 +362,7 @@ div.dialog_head { } div.dialog_body { - padding: 8px 8px 16px; + padding: 8px 4px 16px 4px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js index bc0a145173..391bbcd8ae 100644 --- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js +++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js @@ -42,27 +42,31 @@ cur_frm.cscript.onload = function(doc,dt,dn) { } cur_frm.cscript.onload_post_render = function(doc, dt, dn) { - var callback2 = null; - if(doc.customer && doc.__islocal) { + var callback = function(doc, dt, dn) { // called from mapper, update the account names for items and customer - callback2 = function(doc, dt, dn) { - $c_obj(make_doclist(doc.doctype,doc.name), - 'load_default_accounts','', - function(r,rt) { - refresh_field('entries'); - cur_frm.cscript.customer(doc,dt,dn,onload=true); - } - ); + var callback2 = function(doc, dt, dn) { + if(doc.customer && doc.__islocal) { + $c_obj(make_doclist(doc.doctype,doc.name), + 'load_default_accounts','', + function(r,rt) { + refresh_field('entries'); + cur_frm.cscript.customer(doc,dt,dn,onload=true); + } + ); + } + } + // defined in sales_common.js + var callback1 = function(doc, dt, dn) { + //for previously created sales invoice, set required field related to pos + cur_frm.cscript.update_item_details(doc, dt, dn, callback2); } - } - // defined in sales_common.js - var callback1 = function(doc, dt, dn) { - //for previously created sales invoice, set required field related to pos - cur_frm.cscript.update_item_details(doc, dt, dn, callback2); - } - if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn,callback1); - else cur_frm.cscript.update_item_details(doc, dt, dn, callback2); + if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn,callback1); + else cur_frm.cscript.update_item_details(doc, dt, dn, callback2); + } + + cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); + } @@ -97,16 +101,11 @@ cur_frm.cscript.hide_fields = function(doc, cdt, cdn) { cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.cscript.is_opening(doc, dt, dn); cur_frm.cscript.hide_fields(doc, dt, dn); - - var callback = function() { - cur_frm.cscript.dynamic_label(doc, dt, dn); - } - cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); - - // Show / Hide button cur_frm.clear_custom_buttons(); + if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, dt, dn); + if(doc.docstatus==1) { cur_frm.add_custom_button('View Ledger', cur_frm.cscript['View Ledger Entry']); cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']); diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py index 03fd7620ca..d09adc2e64 100644 --- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py +++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py @@ -167,16 +167,19 @@ class DocType(TransactionBase): # Item Details # ------------- def get_item_details(self, args=None): - args = eval(args) - if args['item_code']: + args = args and eval(args) or {} + if args.get('item_code'): ret = get_obj('Sales Common').get_item_details(args, self) return self.get_pos_details(args, ret) else: obj = get_obj('Sales Common') for doc in self.doclist: if doc.fields.get('item_code'): - ret = obj.get_item_details(doc.item_code, self) - ret = self.get_pos_details(doc.item_code, ret) + arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), + 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')}; + + ret = obj.get_item_details(arg, self) + ret = self.get_pos_details(arg, ret) for r in ret: if not doc.fields.get(r): doc.fields[r] = ret[r] @@ -205,14 +208,6 @@ class DocType(TransactionBase): get_obj('Sales Common').get_adj_percent(self) - def get_comp_base_currency(self): - return get_obj('Sales Common').get_comp_base_currency(self.doc.company) - - def get_price_list_currency(self): - return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company) - - - # Get tax rate if account type is tax # ------------------------------------ def get_rate(self,arg): diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 2a130a59cb..7f40782d0c 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -50,8 +50,11 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { } cur_frm.cscript.onload_post_render = function(doc, dt, dn) { - // defined in sales_common.js - cur_frm.cscript.update_item_details(doc, cdt, cdn); + var callback = function(doc, dt, dn) { + // defined in sales_common.js + cur_frm.cscript.update_item_details(doc, dt, dn); + } + cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); } // hide - unhide fields based on lead or customer.. @@ -83,10 +86,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.clear_custom_buttons(); - var callback = function() { - cur_frm.cscript.dynamic_label(doc, cdt, cdn); - } - cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback); + if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn); if(doc.docstatus == 1 && doc.status!='Order Lost') { diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 531de21ed4..de4056d2d6 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -77,14 +77,16 @@ class DocType(TransactionBase): # Get Item Details # ----------------- def get_item_details(self, args=None): - args = eval(args) - if args['item_code']: + args = args and eval(args) or {} + if args.get('item_code'): return get_obj('Sales Common').get_item_details(args, self) else: obj = get_obj('Sales Common') for doc in self.doclist: if doc.fields.get('item_code'): - ret = obj.get_item_details(doc.item_code, self) + arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), + 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')}; + ret = obj.get_item_details(arg, self) for r in ret: if not doc.fields.get(r): doc.fields[r] = ret[r] @@ -96,11 +98,6 @@ class DocType(TransactionBase): get_obj('Sales Common').get_adj_percent(self) - def get_comp_base_currency(self): - return get_obj('Sales Common').get_comp_base_currency(self.doc.company) - - def get_price_list_currency(self): - return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company) # OTHER CHARGES TRIGGER FUNCTIONS diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js index 5d88c3034b..b9bff5c37a 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.js +++ b/erpnext/selling/doctype/sales_common/sales_common.js @@ -75,7 +75,6 @@ cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) { - // ============== Customer and its primary contact Details ============================ cur_frm.cscript.customer = function(doc, cdt, cdn) { if(doc.customer){ @@ -136,17 +135,11 @@ var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) { // Change label dynamically based on currency //------------------------------------------------------------------ -cur_frm.cscript.dynamic_label = function(doc, cdt, cdn) { - var callback = function(r, rt) { - if (r.message) base_curr = r.message; - else base_curr = sys_defaults['currency']; +cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, base_curr, callback) { + set_dynamic_label_par(doc, cdt, cdn, base_curr); + set_dynamic_label_child(doc, cdt, cdn, base_curr); - set_dynamic_label_par(doc, cdt, cdn, base_curr); - set_dynamic_label_child(doc, cdt, cdn, base_curr); - } - - if (doc.company == sys_defaults['company']) callback('', ''); - else $c_obj(make_doclist(doc.doctype, doc.name), 'get_comp_base_currency', '', callback); + if (callback) callback(doc, cdt, cdn); } @@ -155,27 +148,30 @@ cur_frm.cscript.dynamic_label = function(doc, cdt, cdn) { cur_frm.cscript.hide_price_list_currency = function(doc, cdt, cdn, callback1) { if (doc.price_list_name && doc.currency) { - var callback = function(r, rt) { - pl_currency = r.message[0]?r.message[0]:[]; - if (pl_currency.length==1) { - if (pl_currency[0] == doc.currency) set_multiple(cdt, cdn, {price_list_currency:doc.currency, plc_conversion_rate:doc.conversion_rate}); - else if (pl_currency[0] = r.message[1]) set_multiple(cdt, cdn, {price_list_currency:pl_currency[0], plc_conversion_rate:1}) - hide_field(['price_list_currency', 'plc_conversion_rate']); - } else unhide_field(['price_list_currency', 'plc_conversion_rate']); + wn.call({ + method: 'selling.doctype.sales_common.sales_common.get_price_list_currency', + args: {'price_list':doc.price_list_name, 'company': doc.company}, + callback: function(r, rt) { + pl_currency = r.message[0]?r.message[0]:[]; + if (pl_currency.length==1) { + if (pl_currency[0] == doc.currency) set_multiple(cdt, cdn, {price_list_currency:doc.currency, plc_conversion_rate:doc.conversion_rate}); + else if (pl_currency[0] = r.message[1]) set_multiple(cdt, cdn, {price_list_currency:pl_currency[0], plc_conversion_rate:1}) + hide_field(['price_list_currency', 'plc_conversion_rate']); + } else unhide_field(['price_list_currency', 'plc_conversion_rate']); - if (r.message[1] == doc.currency) { - set_multiple(cdt, cdn, {conversion_rate:1}); - hide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']); - } else unhide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']); + if (r.message[1] == doc.currency) { + set_multiple(cdt, cdn, {conversion_rate:1}); + hide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']); + } else unhide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']); - if (r.message[1] == doc.price_list_currency) { - set_multiple(cdt, cdn, {plc_conversion_rate:1}); - hide_field('plc_conversion_rate'); - } else unhide_field('plc_conversion_rate'); - - callback1() - } - $c_obj(make_doclist(doc.doctype, doc.name), 'get_price_list_currency', '', callback); + if (r.message[1] == doc.price_list_currency) { + set_multiple(cdt, cdn, {plc_conversion_rate:1}); + hide_field('plc_conversion_rate'); + } else unhide_field('plc_conversion_rate'); + + cur_frm.cscript.dynamic_label(doc, cdt, cdn, r.message[1], callback1); + } + }) } } @@ -213,12 +209,15 @@ cur_frm.cscript.conversion_rate = cur_frm.cscript.currency; cur_frm.cscript.plc_conversion_rate = cur_frm.cscript.currency; cur_frm.cscript.company = function(doc, dt, dn) { - var callback = function(r, rt) { - var doc = locals[dt][dn]; - set_multiple(doc.doctype, doc.name, {currency:r.message,price_list_currency:r.message}); - cur_frm.cscript.currency(doc, cdt, cdn); - } - $c_obj(make_doclist(doc.doctype, doc.name), 'get_comp_base_currency', '', callback); + wn.call({ + method: 'selling.doctype.sales_common.sales_common.get_comp_base_currency', + args: {company:doc.company}, + callback: function(r, rt) { + var doc = locals[dt][dn]; + set_multiple(doc.doctype, doc.name, {currency:r.message, price_list_currency:r.message}); + cur_frm.cscript.currency(doc, cdt, cdn); + } + }); } @@ -234,7 +233,6 @@ cur_frm.cscript.price_list_name = function(doc, cdt, cdn) { refresh_field(fname); var doc = locals[cdt][cdn]; cur_frm.cscript.recalc(doc,3); //this is to re-calculate BASIC RATE and AMOUNT on basis of changed REF RATE - cur_frm.cscript.dynamic_label(doc, cdt, cdn); } ); } diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py index 003c3bd7f3..a5017c2ef0 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.py +++ b/erpnext/selling/doctype/sales_common/sales_common.py @@ -178,18 +178,6 @@ class DocType(TransactionBase): d.export_amount = flt(d.qty)*flt(base_ref_rate)/flt(obj.doc.conversion_rate) - def get_comp_base_currency(self, comp): - """ get default currency of company""" - return webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", comp)[0][0] - - def get_price_list_currency(self, price_list, comp): - """ Get all currency in which price list is maintained""" - plc = webnotes.conn.sql("select distinct ref_currency from `tabRef Rate Detail` where price_list_name = %s", price_list) - plc = [d[0] for d in plc] - base_currency = self.get_comp_base_currency(comp) - return plc, base_currency - - # Load Default Taxes # ==================== def load_default_taxes(self, obj): @@ -781,3 +769,17 @@ class StatusUpdater: where name="%(name)s" """ % args) + + +@webnotes.whitelist() +def get_comp_base_currency(arg=None): + """ get default currency of company""" + return webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", webnotes.form_dict['company'])[0][0] + +@webnotes.whitelist() +def get_price_list_currency(arg=None): + """ Get all currency in which price list is maintained""" + plc = webnotes.conn.sql("select distinct ref_currency from `tabRef Rate Detail` where price_list_name = %s", webnotes.form_dict['price_list']) + plc = [d[0] for d in plc] + base_currency = get_comp_base_currency(webnotes.form_dict['company']) + return plc, base_currency diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 4a724d2add..a04423dd25 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -41,10 +41,15 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { } cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) { - if(doc.__islocal) { - // defined in sales_common.js - cur_frm.cscript.update_item_details(doc, cdt, cdn); + var callback = function(doc, cdt, cdn) { + if(doc.__islocal) { + // defined in sales_common.js + cur_frm.cscript.update_item_details(doc, cdt, cdn); + } } + + cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback); + } @@ -52,10 +57,8 @@ cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) { //================== cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.clear_custom_buttons(); - var callback = function() { - cur_frm.cscript.dynamic_label(doc, cdt, cdn); - } - cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback); + + if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn); if(doc.docstatus==1) { diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 943a1fd8e0..c886ec38b6 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -102,14 +102,16 @@ class DocType(TransactionBase): # Get Item Details # ---------------- def get_item_details(self, args=None): - args = eval(args) - if args['item_code']: + args = args and eval(args) or {} + if args.get('item_code'): return get_obj('Sales Common').get_item_details(args, self) else: obj = get_obj('Sales Common') for doc in self.doclist: if doc.fields.get('item_code'): - ret = obj.get_item_details(doc.item_code, self) + arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), + 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')}; + ret = obj.get_item_details(arg, self) for r in ret: if not doc.fields.get(r): doc.fields[r] = ret[r] @@ -120,13 +122,6 @@ class DocType(TransactionBase): def get_adj_percent(self, arg=''): get_obj('Sales Common').get_adj_percent(self) - def get_comp_base_currency(self): - return get_obj('Sales Common').get_comp_base_currency(self.doc.company) - - def get_price_list_currency(self): - return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company) - - # Get projected qty of item based on warehouse selected diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 3a8931e1e7..b0569fcaaf 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -43,17 +43,19 @@ cur_frm.cscript.onload = function(doc, dt, dn) { cur_frm.cscript.onload_post_render = function(doc, dt, dn) { // defined in sales_common.js - if(doc.__islocal) cur_frm.cscript.update_item_details(doc, dt, dn); + var callback = function(doc, dt, dn) { + if(doc.__islocal) cur_frm.cscript.update_item_details(doc, dt, dn); + } + + cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); } // REFRESH // ================================================================================================ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.clear_custom_buttons(); - var callback = function() { - cur_frm.cscript.dynamic_label(doc, cdt, cdn); - } - cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback); + + if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn); if(doc.per_billed < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']); diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index a94531b555..0bca9d0e9e 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -117,14 +117,16 @@ class DocType(TransactionBase): # ***************** Get Item Details ****************************** def get_item_details(self, args=None): - args = eval(args) - if args['item_code']: + args = args and eval(args) or {} + if args.get('item_code'): return get_obj('Sales Common').get_item_details(args, self) else: obj = get_obj('Sales Common') for doc in self.doclist: if doc.fields.get('item_code'): - ret = obj.get_item_details(doc.item_code, self) + arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), + 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')}; + ret = obj.get_item_details(arg, self) for r in ret: if not doc.fields.get(r): doc.fields[r] = ret[r] @@ -135,13 +137,6 @@ class DocType(TransactionBase): get_obj('Sales Common').get_adj_percent(self) - def get_comp_base_currency(self): - return get_obj('Sales Common').get_comp_base_currency(self.doc.company) - - def get_price_list_currency(self): - return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company) - - # ********** Get Actual Qty of item in warehouse selected ************* def get_actual_qty(self,args): args = eval(args) diff --git a/version.num b/version.num index 3879e48b52..5d1d1b123b 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -753 \ No newline at end of file +755 \ No newline at end of file From 428929b1f7588e910bb5666151773437e2482e99 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 1 Mar 2012 11:24:45 +0530 Subject: [PATCH 23/81] fixed permissions --- erpnext/home/page/desktop/desktop.js | 5 ++++- erpnext/startup/js/toolbar.js | 8 +++++++- erpnext/startup/startup.js | 7 ++++++- js/all-app.js | 9 ++++++--- js/all-web.js | 5 +++-- version.num | 2 +- 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/erpnext/home/page/desktop/desktop.js b/erpnext/home/page/desktop/desktop.js index 3aa9049e55..47b11e6f9e 100644 --- a/erpnext/home/page/desktop/desktop.js +++ b/erpnext/home/page/desktop/desktop.js @@ -79,10 +79,13 @@ erpnext.desktop.render = function() { for(var i in wn.boot.modules_list) { var m = wn.boot.modules_list[i]; - if(m!='Setup') + if(m!='Setup' && wn.boot.profile.allow_modules.indexOf(m)!=-1) add_icon(m); } + if(user_roles.indexOf('Accounts Manager')!=-1) + add_icon('Dashboard') + if(user_roles.indexOf('System Manager')!=-1) add_icon('Setup') diff --git a/erpnext/startup/js/toolbar.js b/erpnext/startup/js/toolbar.js index 1a2bfdfe9a..7bf9c6a04e 100644 --- a/erpnext/startup/js/toolbar.js +++ b/erpnext/startup/js/toolbar.js @@ -87,7 +87,7 @@ erpnext.toolbar.add_modules = function() { for(var i in wn.boot.modules_list) { var m = wn.boot.modules_list[i] - if(m!='Setup') { + if(m!='Setup' && wn.boot.profile.allow_modules.indexOf(m)!=-1) { args = { module: m, module_page: erpnext.modules[m], @@ -98,6 +98,12 @@ erpnext.toolbar.add_modules = function() { data-module="%(module)s">%(module_label)s
  • ', args)); } } + + // dasboard for accounts system manager + if(user_roles.indexOf("Accounts Manager")!=-1) { + $('.navbar .modules').append('
  • Dashboard
  • '); + } // setup for system manager if(user_roles.indexOf("System Manager")!=-1) { diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js index ad8289e9d5..9a281e25e8 100644 --- a/erpnext/startup/startup.js +++ b/erpnext/startup/startup.js @@ -34,7 +34,8 @@ erpnext.modules = { 'To Do': 'todo', 'Calendar': 'calendar', 'Messages': 'messages', - 'Knowledge Base': 'questions' + 'Knowledge Base': 'questions', + 'Dashboard': 'dashboard' } erpnext.startup.set_globals = function() { @@ -59,6 +60,10 @@ erpnext.startup.start = function() { wn.title_prefix = wn.boot.website_settings.title_prefix; } } else { + // always allow apps + wn.boot.profile.allow_modules = wn.boot.profile.allow_modules.concat( + ['To Do', 'Knowledge Base', 'Calendar', 'Activity']) + // setup toolbar erpnext.toolbar.setup(); diff --git a/js/all-app.js b/js/all-app.js index be01071a0b..24bb1288ba 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -2229,12 +2229,13 @@ wn.modules_path='erpnext';wn.settings.no_history=true;$(document).bind('ready',f /* * erpnext/startup/startup.js */ -var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions'} +var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions','Dashboard':'dashboard'} erpnext.startup.set_globals=function(){pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway) if(inList(user_roles,'System Manager'))is_system_manager=1;} erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.custom_css){set_style(wn.boot.custom_css);} if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);} -if(user=='Guest'){if(wn.boot.website_settings.title_prefix){wn.title_prefix=wn.boot.website_settings.title_prefix;}}else{erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();$('footer').html('