Merge branch 'latest' of github.com:webnotes/erpnext into latest
diff --git a/erpnext/home/page/dashboard/dashboard.js b/erpnext/home/page/dashboard/dashboard.js
index aac42a3..8ef2ffb 100644
--- a/erpnext/home/page/dashboard/dashboard.js
+++ b/erpnext/home/page/dashboard/dashboard.js
@@ -1,6 +1,7 @@
pscript.onload_dashboard = function() {
// load jqplot
$.scriptPath = 'js/'
+ wn.require('lib/css/jqpot.css');
wn.require('lib/js/legacy/jquery/jquery.jqplot.min.js');
wn.require('lib/js/legacy/jquery/jqplot-plugins/jqplot.barRenderer.js');
wn.require('lib/js/legacy/jquery/jqplot-plugins/jqplot.canvasAxisTickRenderer.min.js');
diff --git a/erpnext/home/page/my_company/my_company.py b/erpnext/home/page/my_company/my_company.py
index c239162..09bb9ee 100644
--- a/erpnext/home/page/my_company/my_company.py
+++ b/erpnext/home/page/my_company/my_company.py
@@ -1,6 +1,7 @@
import webnotes
from webnotes.utils import cint, load_json, cstr
+from webnotes.model.doc import Document
try: import json
except: import simplejson as json
@@ -65,8 +66,7 @@
# add profile record
#
def add_profile(args):
- from webnotes.utils import validate_email_add
- from webnotes.model.doc import Document
+ from webnotes.utils import validate_email_add, now
email = args['user']
sql = webnotes.conn.sql
@@ -80,7 +80,7 @@
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')
+ webnotes.msgprint('Profile exists, enabled it with new password')
else:
# does not exist, create it!
pr = Document('Profile')
@@ -92,11 +92,25 @@
pr.user_type = 'System User'
pr.save(1)
- if args.get('password'):
- sql("""
- UPDATE tabProfile
- SET password = PASSWORD(%s)
- WHERE name = %s""", (args.get('password'), email))
+ 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.get('password'))
+
+def send_welcome_mail(email, password):
+ """send welcome mail to user with password and login url"""
+ pr = Document('Profile', email)
+ from webnotes.utils.email_lib import sendmail_md
+ args = {
+ 'company': webnotes.conn.get_default('company'),
+ 'name': email,
+ 'password': password,
+ 'account_url': webnotes.conn.get_default('account_url')
+ }
+ sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args)
#
# post comment
@@ -166,3 +180,18 @@
else:
webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", (args['new_password'], args['user']))
else: webnotes.msgprint('Settings Updated')
+
+welcome_txt = """
+## %(company)s
+
+#### Welcome!
+
+A new account has been created for you, here are your details:
+
+login-id: %(name)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/patches/jan_mar_2012/subdomain_login_patch.py b/erpnext/patches/jan_mar_2012/subdomain_login_patch.py
index 9c72b0e..edfcb66 100644
--- a/erpnext/patches/jan_mar_2012/subdomain_login_patch.py
+++ b/erpnext/patches/jan_mar_2012/subdomain_login_patch.py
@@ -2,8 +2,10 @@
from webnotes.model.doc import Document
def execute():
+ from webnotes.modules import reload_doc
add_default_home_page()
cleanup()
+ reload_doc('setup','doctype','manage_account')
def cleanup():
from webnotes.model import delete_doc
@@ -19,4 +21,4 @@
d.parentfield = 'default_home_pages'
d.role = 'Guest'
d.home_page = 'Login Page'
- d.save(1)
\ No newline at end of file
+ d.save(1)
diff --git a/erpnext/setup/doctype/manage_account/manage_account.js b/erpnext/setup/doctype/manage_account/manage_account.js
index 7c3b193..63cc1d5 100644
--- a/erpnext/setup/doctype/manage_account/manage_account.js
+++ b/erpnext/setup/doctype/manage_account/manage_account.js
@@ -1,6 +1,6 @@
// Validate
cur_frm.cscript.validate = function(doc, cdt, cdn) {
- $c_obj(make_doclist(cdt, cdn), 'update_cp', '', function(r, rt){
+ $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){
sys_defaults = r.message;
});
}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/manage_account/manage_account.py b/erpnext/setup/doctype/manage_account/manage_account.py
index 5b1292a..757d323 100644
--- a/erpnext/setup/doctype/manage_account/manage_account.py
+++ b/erpnext/setup/doctype/manage_account/manage_account.py
@@ -1,66 +1,60 @@
-# Please edit this list and import only required elements
+"""Global Defaults"""
import webnotes
-from webnotes.utils import cint, cstr, get_defaults, set_default, fmt_money, get_last_day, get_first_day
-from webnotes import session, form, is_testing, msgprint, errprint
-
-sql = webnotes.conn.sql
-
-
-# -----------------------------------------------------------------------------------------
-
+keydict = {
+ "fiscal_year": "current_fiscal_year",
+ 'company': 'default_company',
+ 'currency': 'default_currency',
+ 'price_list_name': 'default_price_list',
+ 'price_list_currency': 'default_price_list_currency',
+ 'item_group': 'default_item_group',
+ 'customer_group': 'default_customer_group',
+ 'cust_master_name': 'cust_master_name',
+ 'supplier_type': 'default_supplier_type',
+ 'supp_master_name': 'supp_master_name',
+ 'territory': 'default_territory',
+ 'stock_uom': 'default_stock_uom',
+ 'fraction_currency': 'default_currency_fraction',
+ 'valuation_method': 'default_valuation_method',
+ 'date_format': 'date_format',
+ 'currency_format':'default_currency_format',
+ 'account_url':'account_url'
+}
class DocType:
- def __init__(self, d, dl):
- self.doc, self.doclist = d, dl
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
-#---------------------------------------------------------------------------------------------------------------------------------------------
- def get_bal(self,arg):
- bal = sql("select `tabAccount Balance`.balance,`tabAccount`.debit_or_credit from `tabAccount`,`tabAccount Balance` where `tabAccount Balance`.account=%s and `tabAccount Balance`.period=%s and `tabAccount Balance`.account=`tabAccount`.name ",(arg,self.doc.current_fiscal_year))
- if bal:
- return fmt_money(flt(bal[0][0])) + ' ' + bal[0][1]
-
-
-# =========================================================================================================================================
-
- # Update Default
- # ---------------
- def set_system_default(self, defkey, defvalue):
- set_default(defkey, defvalue)
-
- if defkey == 'fiscal_year':
- ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", cstr(defvalue))
- ysd = ysd and ysd[0][0] or ''
- if ysd:
- set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
- set_default('year_end_date', get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
-
-
- # Update
- # --------
- def update_cp(self):
- def_list = [['fiscal_year',self.doc.current_fiscal_year],
- ['company',self.doc.default_company],
- ['currency',self.doc.default_currency],
- ['price_list_name',self.doc.default_price_list or ''],
- ['price_list_currency', self.doc.default_price_list_currency or ''],
- ['item_group',self.doc.default_item_group or ''],
- ['customer_group',self.doc.default_customer_group or ''],
- ['cust_master_name',self.doc.cust_master_name or ''],
- ['supplier_type',self.doc.default_supplier_type or ''],
- ['supp_master_name',self.doc.supp_master_name],
- ['territory',self.doc.default_territory or ''],
- ['stock_uom',self.doc.default_stock_uom or ''],
- ['fraction_currency',self.doc.default_currency_fraction or ''],
- ['valuation_method',self.doc.default_valuation_method]]
-
- for d in def_list:
- self.set_system_default(d[0],d[1])
- # Update Currency Format
+ def get_bal(self,arg):
+ """get account balance (??)"""
+ from webnotes.utils import fmt_money, flt
+ bal = webnotes.conn.sql("select `tabAccount Balance`.balance,`tabAccount`.debit_or_credit from `tabAccount`,`tabAccount Balance` where `tabAccount Balance`.account=%s and `tabAccount Balance`.period=%s and `tabAccount Balance`.account=`tabAccount`.name ",(arg,self.doc.current_fiscal_year))
+ if bal:
+ return fmt_money(flt(bal[0][0])) + ' ' + bal[0][1]
- sql("update `tabSingles` set value = '%s' where field = 'currency_format' and doctype = 'Control Panel'" % self.doc.default_currency_format)
- sql("update `tabSingles` set value = '%s' where field = 'date_format' and doctype = 'Control Panel'" %self.doc.date_format)
-
-
- return get_defaults()
-
+ def validate(self):
+ """validate"""
+ if not (self.doc.account_url and (self.doc.account_url.startswith('http://') \
+ or self.doc.account_url.startswith('https://'))):
+ webnotes.msgprint("Account URL must start with 'http://' or 'https://'", raise_exception=1)
+
+ def on_update(self):
+ """update defaults"""
+ self.validate()
+
+ for key in keydict:
+ webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
+
+ # update year start date and year end date from fiscal_year
+ ysd = webnotes.conn.sql("""select year_start_date from `tabFiscal Year`
+ where name=%s""", self.doc.fiscal_year)
+
+ ysd = ysd and ysd[0][0] or ''
+ from webnotes.utils import get_first_day, get_last_day
+ if ysd:
+ webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
+ webnotes.conn.set_default('year_end_date', \
+ get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
+
+ def get_defaults(self):
+ return webnotes.conn.get_defaults()
\ No newline at end of file
diff --git a/erpnext/setup/doctype/manage_account/manage_account.txt b/erpnext/setup/doctype/manage_account/manage_account.txt
index 8a156a0..18a9872 100644
--- a/erpnext/setup/doctype/manage_account/manage_account.txt
+++ b/erpnext/setup/doctype/manage_account/manage_account.txt
@@ -5,14 +5,13 @@
{
'creation': '2010-08-08 17:09:09',
'docstatus': 0,
- 'modified': '2011-12-21 13:22:33',
+ 'modified': '2012-01-20 11:25:18',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
-
'_last_update': '1323855502',
'allow_copy': 1,
'allow_email': 1,
@@ -29,7 +28,7 @@
'section_style': 'Tabbed',
'server_code_error': ' ',
'show_in_menu': 1,
- 'version': 515
+ 'version': 517
},
# These values are common for all DocField
@@ -106,6 +105,37 @@
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
+ 'label': 'System'
+ },
+
+ # DocField
+ {
+ 'colour': 'White:FFF',
+ 'description': 'Example: http://frappe.erpnext.com',
+ 'doctype': 'DocField',
+ 'fieldname': 'account_url',
+ 'fieldtype': 'Data',
+ 'label': 'Account URL'
+ },
+
+ # DocField
+ {
+ 'doctype': 'DocField',
+ 'fieldtype': 'Column Break'
+ },
+
+ # DocField
+ {
+ 'doctype': 'DocField',
+ 'fieldname': 'sms_sender_name',
+ 'fieldtype': 'Data',
+ 'label': 'SMS Sender Name'
+ },
+
+ # DocField
+ {
+ 'doctype': 'DocField',
+ 'fieldtype': 'Section Break',
'label': 'Company'
},
@@ -176,14 +206,6 @@
# DocField
{
'doctype': 'DocField',
- 'fieldname': 'sms_sender_name',
- 'fieldtype': 'Data',
- 'label': 'SMS Sender Name'
- },
-
- # DocField
- {
- 'doctype': 'DocField',
'fieldtype': 'Section Break',
'label': 'Stock'
},
@@ -510,4 +532,4 @@
'label': 'Employee Records to be created by ',
'options': '\nNaming Series\nEmployee Number'
}
-]
+]
\ No newline at end of file
diff --git a/erpnext/utilities/doctype/profile_control/profile_control.py b/erpnext/utilities/doctype/profile_control/profile_control.py
index 189d8b1..b8db231 100644
--- a/erpnext/utilities/doctype/profile_control/profile_control.py
+++ b/erpnext/utilities/doctype/profile_control/profile_control.py
@@ -22,66 +22,9 @@
self.doc, self.doclist = d,dl
self.last_profile = None
- # Sync Profile with Gateway
- # -------------------------
- def sync_with_gateway(self,pid):
- p = Document('Profile',pid)
-
- # login to gateway
- from webnotes.utils.webservice import FrameworkServer
- fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
-
- account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
-
- # call add profile
- ret = fw.runserverobj('Profile Control','Profile Control','add_profile_gateway',str([p.first_name, p.middle_name, p.last_name, p.email, p.name, account_id]))
-
- if ret.get('exc'):
- msgprint(ret['exc'])
- raise Exception
-
def get_role_permission(self,role):
perm = sql("select distinct t1.`parent`, t1.`read`, t1.`write`, t1.`create`, t1.`submit`,t1.`cancel`,t1.`amend` from `tabDocPerm` t1, `tabDocType` t2 where t1.`role` ='%s' and t1.docstatus !=2 and t1.permlevel = 0 and t1.`read` = 1 and t2.module != 'Recycle Bin' and t1.parent=t2.name "%role)
return perm or ''
-
-
- # Check if password is expired
- # --------------------------------
- def has_pwd_expired(self):
- if session['user'] != 'Administrator' and session['user'].lower() != 'demo':
- last_pwd_date = None
- try:
- last_pwd_date = sql("select password_last_updated from tabProfile where name=%s",session['user'])[0][0] or ''
- except:
- return 'No'
- if cstr(last_pwd_date) == '':
- sql("update tabProfile set password_last_updated = '%s' where name='%s'"% (nowdate(),session['user']))
- return 'No'
- else:
- date_diff = (getdate(nowdate()) - last_pwd_date).days
- expiry_period = sql("select value from tabSingles where doctype='Control Panel' and field='password_expiry_days'")
- if expiry_period and cint(expiry_period[0][0]) and cint(expiry_period[0][0]) < date_diff:
- return 'Yes'
- return 'No'
-
- def reset_password(self,pwd):
- if sql("select name from tabProfile where password=PASSWORD(%s) and name=%s", (pwd,session['user'])):
- return 'Password cannot be same as old password'
- sql("update tabProfile set password=PASSWORD(%s),password_last_updated=%s where name = %s", (pwd,nowdate(),session['user']))
- return 'ok'
-
-#-------------------------------------------------------------------------------------------------------
- #functions for manage user page
- #-----------Enable/Disable Profile-----------------------------------------------------------------------------------------------
- def change_login(self,args):
- args = eval(args)
-
- if cint(args['set_disabled'])==0:
- sql("update `tabProfile` set enabled=1 where name='%s'"%args['user'])
- else:
- sql("update `tabProfile` set enabled=0 where name='%s'"%args['user'])
-
- return 'ok'
#------------return role list -------------------------------------------------------------------------------------------------
# All roles of Role Master
@@ -113,75 +56,3 @@
pr.parentfield = 'userroles'
pr.save(1)
-
-
- # Add new member
- # ---------------
- def add_profile(self,arg):
-
- # Check credit balance
- get_obj('WN ERP Client Control').check_credit_balance()
-
- arg=eval(arg)
- pr=Document('Profile')
- for d in arg.keys():
- if d!='role':
- pr.fields[d] = arg[d]
-
- pr.enabled=0
- pr.user_type='System User'
- pr.save(1)
- pr_obj = get_obj('Profile',pr.name)
- if (pr.name):
- msg="New member is added"
- pr_obj.on_update()
- else:
- msg="Profile not created"
-
- return cstr(msg)
-
- # to find currently login user
- def current_login(self):
- cl_list=sql("select distinct user from tabSessions")
- if cl_list:
- cl_list=[x[0] for x in cl_list]
-
- return cl_list
-
-
- # Remove Profile
- # ---------------
- def remove_profile(self, user):
- # delete profile
- webnotes.model.delete_doc('Profile',user)
-
- # Update WN ERP Client Control
- sql("update tabSingles set value = value - 1 where field = 'total_users' and doctype = 'WN ERP Client Control'")
-
- # login to gateway
- from webnotes.utils.webservice import FrameworkServer
- fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
-
- account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
-
- # call remove profile
- ret = fw.runserverobj('Profile Control','Profile Control','remove_app_sub',str([user, account_id, session['user']]))
-
- if ret.get('exc'):
- msgprint(ret['exc'])
- raise Exception
-
- return "User Removed Successfully"
-
-
- # Create Profile
- # ---------------
- def create_profile(self, email):
- if sql("select name from tabProfile where name = %s", email):
- sql("update tabProfile set docstatus = 0 where name = %s", email)
- else:
- pr = Document('Profile')
- pr.email = email
- pr.enabled=0
- pr.user_type='System User'
- pr.save(1)
diff --git a/index.html b/index.html
index ebe217b..076064a 100644
--- a/index.html
+++ b/index.html
@@ -3,7 +3,8 @@
<meta charset="utf-8">
<title>ERPNext</title>
<meta name="author" content="">
- <script type="text/javascript">window._version_number="49"
+ <script type="text/javascript">window._version_number="52"
+
wn={}
wn.provide=function(namespace){var nsl=namespace.split('.');var l=nsl.length;var parent=window;for(var i=0;i<l;i++){var n=nsl[i];if(!parent[n]){parent[n]={}}
parent=parent[n];}}
diff --git a/version.num b/version.num
index 2e66562..6139554 100644
--- a/version.num
+++ b/version.num
@@ -1 +1 @@
-49
\ No newline at end of file
+52
\ No newline at end of file