Merge branch 'latest' of github.com:webnotes/erpnext into latest
diff --git a/erpnext/accounts/__init__.py b/erpnext/accounts/__init__.py
index c3c5005..65d0231 100644
--- a/erpnext/accounts/__init__.py
+++ b/erpnext/accounts/__init__.py
@@ -2,6 +2,7 @@
 from webnotes.utils import flt
 from webnotes.model.code import get_obj
 
+@webnotes.whitelist()
 def get_default_bank_account():
 	"""
 		Get default bank account for a company
@@ -14,7 +15,7 @@
 	
 	if res: return res[0][0]
 
-
+@webnotes.whitelist()
 def get_new_jv_details():
 	"""
 		Get details which will help create new jv on sales/purchase return
diff --git a/erpnext/home/page/dashboard/dashboard.py b/erpnext/home/page/dashboard/dashboard.py
index c2378d3..e8f11fb 100644
--- a/erpnext/home/page/dashboard/dashboard.py
+++ b/erpnext/home/page/dashboard/dashboard.py
@@ -54,11 +54,12 @@
 	}
 ]
 
+import webnotes
+
 class DashboardWidget:
 	def __init__(self, company, start, end, interval):
 		from webnotes.utils import getdate
 		from webnotes.model.code import get_obj
-		import webnotes
 		
 		self.company = company
 		self.abbr = webnotes.conn.get_value('Company', company, 'abbr')
@@ -233,7 +234,7 @@
 		elif opts['type']=='creation':
 			return self.get_creation_trend(opts['doctype'], start, end)
 
-
+@webnotes.whitelist()
 def load_dashboard(args):
 	"""
 		Get dashboard based on
diff --git a/erpnext/home/page/event_updates/event_updates.py b/erpnext/home/page/event_updates/event_updates.py
index e4690d0..cb27043 100644
--- a/erpnext/home/page/event_updates/event_updates.py
+++ b/erpnext/home/page/event_updates/event_updates.py
@@ -1,6 +1,7 @@
 import webnotes
 from webnotes.utils import cint
 
+@webnotes.whitelist()
 def get_online_users():
 	# get users
 	return webnotes.conn.sql("""SELECT DISTINCT t1.user, t2.first_name, t2.last_name 
@@ -9,9 +10,7 @@
 		and t1.user not in ('Guest','Administrator')
 		and TIMESTAMPDIFF(HOUR,t1.lastupdate,NOW()) <= 1""", as_list=1) or []
 
-#
-# get unread messages
-#
+@webnotes.whitelist()
 def get_unread_messages():
 	"returns unread (docstatus-0 messages for a user)"
 	return cint(webnotes.conn.sql("""SELECT COUNT(*) FROM `tabComment Widget Record`
@@ -20,10 +19,9 @@
 	AND ifnull(docstatus,0)=0
 	""", webnotes.user.name)[0][0])
 
-#
-# Get toolbar items
-#	
+@webnotes.whitelist()
 def get_status_details(arg=None):
+	"""get toolbar items"""
 	from webnotes.utils import cint, date_diff, nowdate, get_defaults
 		
 	online = get_online_users()
@@ -43,6 +41,7 @@
 	}
 	return ret
 
+@webnotes.whitelist()
 def get_setup_status():
 	"""
 		Returns the setup status of the current account
diff --git a/erpnext/home/page/my_company/my_company.py b/erpnext/home/page/my_company/my_company.py
index 48566f2..8070c9d 100644
--- a/erpnext/home/page/my_company/my_company.py
+++ b/erpnext/home/page/my_company/my_company.py
@@ -6,13 +6,12 @@
 try: import json
 except: import simplejson as json
 
+@webnotes.whitelist()
 def get_account_settings_url(arg=''):
 	import server_tools.gateway_utils
 	return server_tools.gateway_utils.get_account_settings_url()
 
-#
-# set max users
-#
+@webnotes.whitelist()
 def get_max_users(arg=''):
 	from server_tools.gateway_utils import get_max_users_gateway
 	return {
@@ -20,16 +19,12 @@
 		'enabled': cint(webnotes.conn.sql("select count(*) from tabProfile where ifnull(enabled,0)=1 and name not in ('Administrator', 'Guest')")[0][0])
 	}
 
-#
-# enable profile in local
-#
+@webnotes.whitelist()
 def enable_profile(arg=''):
 	webnotes.conn.sql("update tabProfile set enabled=1 where name=%s", arg)
 	return 1
 		
-#
-# disable profile in local
-#
+@webnotes.whitelist()
 def disable_profile(arg=''):
 	if arg=='Administrator':
 		return 'Cannot disable Administrator'
@@ -38,9 +33,7 @@
 	webnotes.login_manager.logout(user=arg)
 	return 0
 
-#
-# delete user
-#
+@webnotes.whitelist()
 def delete_user(args):
 	args = json.loads(args)
 	webnotes.conn.sql("update tabProfile set enabled=0, docstatus=2 where name=%s", args['user'])
@@ -49,9 +42,7 @@
 		from server_tools.gateway_utils import remove_user_gateway
 		remove_user_gateway(args['user'])
 
-#
-# add user
-#
+@webnotes.whitelist()
 def add_user(args):
 	args = json.loads(args)
 	# erpnext-saas
@@ -61,9 +52,7 @@
 	
 	add_profile(args)
 	
-#
-# add profile record
-#
+@webnotes.whitelist()
 def add_profile(args):
 	from webnotes.utils import validate_email_add, now
 	email = args['user']
@@ -99,6 +88,7 @@
 
 	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)
diff --git a/erpnext/home/page/profile_settings/profile_settings.py b/erpnext/home/page/profile_settings/profile_settings.py
index ef969ca..cbfb188 100644
--- a/erpnext/home/page/profile_settings/profile_settings.py
+++ b/erpnext/home/page/profile_settings/profile_settings.py
@@ -2,6 +2,7 @@
 
 from webnotes.utils import load_json, cint, nowdate
 
+@webnotes.whitelist()
 def change_password(arg):
 	"""
 		Change password
@@ -15,12 +16,14 @@
 	webnotes.conn.sql("update tabProfile set password=password(%s), modified=%s where name=%s",(arg['new_password'], nowdate(), webnotes.session['user']))
 	webnotes.msgprint('Password Updated');
 
+@webnotes.whitelist()
 def get_user_details(arg=None):
 	"""
 		Returns user first name, last name and bio
 	"""
 	return webnotes.conn.sql("select first_name, last_name, bio from tabProfile where name=%s", webnotes.user.name, as_dict=1)[0]
 	
+@webnotes.whitelist()
 def set_user_details(arg=None):
 	"""
 		updates user details given in argument
@@ -35,6 +38,7 @@
 	p.save()
 	webnotes.msgprint('Updated')
 
+@webnotes.whitelist()
 def set_user_image(fid, fname):
 	"""
 		Set uploaded image as user image
diff --git a/erpnext/knowledge_base/page/question_view/question_view.py b/erpnext/knowledge_base/page/question_view/question_view.py
index a2eafbc..c711b90 100644
--- a/erpnext/knowledge_base/page/question_view/question_view.py
+++ b/erpnext/knowledge_base/page/question_view/question_view.py
@@ -1,19 +1,22 @@
 import webnotes
 from webnotes.utils import load_json, cstr, now
 
-# update the editable text item
+@webnotes.whitelist()
 def update_item(args):
 	args = load_json(args)
 	
 	webnotes.conn.sql("update `tab%s` set `%s`=%s, modified=%s where name=%s" \
 		% (args['dt'], args['fn'], '%s', '%s', '%s'), (args['text'], now(), args['dn']))
-		
+
+@webnotes.whitelist()
 def has_answered(arg):
 	return webnotes.conn.sql("select name from tabAnswer where owner=%s and question=%s", (webnotes.user.name, arg)) and 'Yes' or 'No'
 
+@webnotes.whitelist()
 def get_question(arg):
 	return cstr(webnotes.conn.sql("select question from tabQuestion where name=%s", arg)[0][0])
 
+@webnotes.whitelist()
 def add_answer(args):
 	args = load_json(args)
 	
diff --git a/erpnext/knowledge_base/page/questions/questions.py b/erpnext/knowledge_base/page/questions/questions.py
index 5f8b209..d3f0d7c 100644
--- a/erpnext/knowledge_base/page/questions/questions.py
+++ b/erpnext/knowledge_base/page/questions/questions.py
@@ -3,6 +3,7 @@
 from webnotes.utils import load_json, cint, cstr
 
 # add a new question
+@webnotes.whitelist()
 def add_question(arg):
 	args = load_json(arg)
 	
@@ -22,7 +23,7 @@
 					'notify': 1
 				})
 	
-	
+@webnotes.whitelist()
 def vote(arg):
 	args = load_json(arg)
 	
@@ -36,6 +37,7 @@
 	
 	return p
 
+@webnotes.whitelist()
 def delete(arg):
 	"""
 		delete a question or answer (called from kb toolbar)
diff --git a/erpnext/selling/page/customers/__init__.py b/erpnext/selling/page/customers/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/selling/page/customers/__init__.py
+++ /dev/null
diff --git a/erpnext/selling/page/customers/customers.html b/erpnext/selling/page/customers/customers.html
deleted file mode 100644
index 9f3d19c..0000000
--- a/erpnext/selling/page/customers/customers.html
+++ /dev/null
@@ -1 +0,0 @@
-<div id="dcv_customers"></div>
\ No newline at end of file
diff --git a/erpnext/selling/page/customers/customers.js b/erpnext/selling/page/customers/customers.js
deleted file mode 100644
index 7902e24..0000000
--- a/erpnext/selling/page/customers/customers.js
+++ /dev/null
@@ -1,34 +0,0 @@
-//make tabs
-
-pscript.onload_customers = function() {
-	make_customer_tab($i('dcv_customers'));
-}
-
-function make_customer_tab(parent) {	
-	pscript.dcv_customers = new wn.widgets.DocColumnView('Customers', parent, 
-		['Customer Group', 'Customer', 'Contact'], {
-		'Customer Group': { 
-			show_fields : ['name'],
-			create_fields : ['name'],
-			search_fields : ['name'],
-			next_col: 'Customer'
-		},
-		'Customer': { 
-			show_fields : ['name', 'customer_name'],
-			create_fields : ['name', 'customer_name'],
-			search_fields : ['customer_name'],
-			filter_by : ['Customer Group', 'customer_group'],
-			next_col: 'Contact'
-		},
-		'Contact': { 
-			show_fields : ['name', 'first_name', 'last_name'],
-			create_fields : ['name','first_name', 'last_name'],
-			search_fields : ['first_name', 'last_name'],
-			conditions: ['is_customer=1'],
-			set_values: {'is_customer': 1 },
-			filter_by : ['Customer', 'customer']
-		},
-	})
-}
-
-
diff --git a/erpnext/selling/page/customers/customers.txt b/erpnext/selling/page/customers/customers.txt
deleted file mode 100644
index 7f44ab45..0000000
--- a/erpnext/selling/page/customers/customers.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
-	{
-		'content': None,
-		'creation': '2011-03-25 13:48:50',
-		'docstatus': 0,
-		'doctype': 'Page',
-		'icon': None,
-		'idx': None,
-		'menu_index': None,
-		'modified': '2011-03-25 13:48:50',
-		'modified_by': 'Administrator',
-		'module': 'CRM',
-		'name': 'customers',
-		'owner': 'Administrator',
-		'page_name': 'Customers',
-		'parent': None,
-		'parent_node': None,
-		'parentfield': None,
-		'parenttype': None,
-		'script': None,
-		'show_in_menu': None,
-		'standard': 'Yes',
-		'static_content': None,
-		'style': None
-	}
-]
\ 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 757d323..eed566e 100644
--- a/erpnext/setup/doctype/manage_account/manage_account.py
+++ b/erpnext/setup/doctype/manage_account/manage_account.py
@@ -30,17 +30,10 @@
 		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]
-	
-	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)
+			return fmt_money(flt(bal[0][0])) + ' ' + bal[0][1]	
 	
 	def on_update(self):
 		"""update defaults"""
-		self.validate()
 		
 		for key in keydict:
 			webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
diff --git a/erpnext/setup/page/people/__init__.py b/erpnext/setup/page/people/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/setup/page/people/__init__.py
+++ /dev/null
diff --git a/erpnext/setup/page/people/people.html b/erpnext/setup/page/people/people.html
deleted file mode 100644
index ad31e38..0000000
--- a/erpnext/setup/page/people/people.html
+++ /dev/null
@@ -1 +0,0 @@
-<div id="crm_home"></div>
\ No newline at end of file
diff --git a/erpnext/setup/page/people/people.js b/erpnext/setup/page/people/people.js
deleted file mode 100644
index fd316bf..0000000
--- a/erpnext/setup/page/people/people.js
+++ /dev/null
@@ -1,32 +0,0 @@
-//make tabs
-
-pscript.onload_people = function() {
-	make_customer_tab($i('crm_home'));
-}
-
-function make_customer_tab(parent) {	
-	new wn.widgets.DocColumnView('Customers', parent, ['Customer Group', 'Customer', 'Contact'], {
-		'Customer Group': { 
-			show_fields : ['name'],
-			create_fields : ['name'],
-			search_fields : ['name'],
-			next_col: 'Customer'
-		},
-		'Customer': { 
-			show_fields : ['name', 'customer_name'],
-			create_fields : ['name', 'customer_name'],
-			search_fields : ['customer_name'],
-			filter_by : ['Customer Group', 'customer_group'],
-			next_col: 'Contact'
-		},
-		'Contact': { 
-			show_fields : ['name', 'first_name', 'last_name'],
-			create_fields : ['name','first_name', 'last_name'],
-			search_fields : ['first_name', 'last_name'],
-			conditions: ['is_customer=1'],
-			filter_by : ['Customer', 'customer']
-		},
-	})
-}
-
-
diff --git a/erpnext/setup/page/people/people.txt b/erpnext/setup/page/people/people.txt
deleted file mode 100644
index 3e7bba2..0000000
--- a/erpnext/setup/page/people/people.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
-	{
-		'content': None,
-		'creation': '2011-03-21 12:12:32',
-		'docstatus': 0,
-		'doctype': 'Page',
-		'icon': None,
-		'idx': None,
-		'menu_index': None,
-		'modified': '2011-03-21 12:13:39',
-		'modified_by': 'Administrator',
-		'module': 'Setup',
-		'name': 'people',
-		'owner': 'Administrator',
-		'page_name': 'People',
-		'parent': None,
-		'parent_node': None,
-		'parentfield': None,
-		'parenttype': None,
-		'script': None,
-		'show_in_menu': None,
-		'standard': 'Yes',
-		'static_content': None,
-		'style': None
-	}
-]
\ No newline at end of file
diff --git a/erpnext/website/doctype/web_page/web_page.py b/erpnext/website/doctype/web_page/web_page.py
index e262bfe..0a1a60e 100644
--- a/erpnext/website/doctype/web_page/web_page.py
+++ b/erpnext/website/doctype/web_page/web_page.py
@@ -10,8 +10,11 @@
 		self.doc.name = website.utils.page_name(self.doc.title)
 
 	def validate(self):
-		"""make page for this product"""					
-		p = website.utils.add_page(self.doc.title)
+		"""make page for this product"""
+		if not self.doc.name:				
+			self.doc.name = website.utils.page_name(self.doc.title)
+
+		p = website.utils.add_page(self.doc.name)
 		
 		from jinja2 import Template
 		from webnotes.utils import global_date_format
diff --git a/erpnext/website/page/blog/blog.py b/erpnext/website/page/blog/blog.py
index 6e7a62e..2773624 100644
--- a/erpnext/website/page/blog/blog.py
+++ b/erpnext/website/page/blog/blog.py
@@ -1,4 +1,6 @@
 import webnotes
+
+@webnotes.whitelist()
 def subscribe(arg):
 	"""subscribe to blog (blog_subscriber)"""
 	if webnotes.conn.sql("""select name from `tabBlog Subscriber` where name=%s""", arg):
diff --git a/erpnext/website/page/contact/contact.py b/erpnext/website/page/contact/contact.py
index a6566a9..2fd00f7 100644
--- a/erpnext/website/page/contact/contact.py
+++ b/erpnext/website/page/contact/contact.py
@@ -1,5 +1,6 @@
 import json, webnotes
 
+@webnotes.whitelist()
 def send(args):
 	"""create support ticket"""
 	args = json.loads(args)
diff --git a/erpnext/website/page/unsubscribe/unsubscribe.py b/erpnext/website/page/unsubscribe/unsubscribe.py
index 57d1d47..c310c61 100644
--- a/erpnext/website/page/unsubscribe/unsubscribe.py
+++ b/erpnext/website/page/unsubscribe/unsubscribe.py
@@ -1,6 +1,8 @@
+import webnotes
+
+@webnotes.whitelist()
 def unsubscribe(arg):
 	"""unsubscribe from lists"""
-	import webnotes
 	lists = [['Blog Subscriber', 'name']]
 	for l in lists:
 		webnotes.conn.sql("""delete from `tab%s` where %s=%s""" % (l[0], l[1], '%s'), arg)
diff --git a/version.num b/version.num
index e41567f..1380537 100644
--- a/version.num
+++ b/version.num
@@ -1 +1 @@
-384
\ No newline at end of file
+385
\ No newline at end of file