Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/erpnext/home/page/profile_settings/profile_settings.js b/erpnext/home/page/profile_settings/profile_settings.js
index 425626b..bcb39b3 100644
--- a/erpnext/home/page/profile_settings/profile_settings.js
+++ b/erpnext/home/page/profile_settings/profile_settings.js
@@ -97,7 +97,12 @@
 			]);	
 
 			var w = d.widgets['wrapper'];
-			me.uploader = new Uploader(w, {cmd:'home.page.profile_settings.profile_settings.set_user_image'}, pscript.user_image_upload, 1)
+			me.uploader = new Uploader(w, 
+				{
+					modulename:'home.page.profile_settings.profile_settings',
+					method: 'set_user_image'
+				}, 
+				pscript.user_image_upload, 1)
 			me.change_dialog = d;
 		}
 		me.change_dialog.show();
diff --git a/erpnext/home/page/profile_settings/profile_settings.py b/erpnext/home/page/profile_settings/profile_settings.py
index d1e091c..ffa0e7f 100644
--- a/erpnext/home/page/profile_settings/profile_settings.py
+++ b/erpnext/home/page/profile_settings/profile_settings.py
@@ -36,24 +36,10 @@
 	p.save()
 	webnotes.msgprint('Updated')
 
-def set_user_image(arg=None):
+def set_user_image(fid, fname):
 	"""
 		Set uploaded image as user image
 	"""
-	from webnotes.utils.upload_handler import UploadHandler
-	
-	uh = UploadHandler()
-	if not uh.file_name:
-		# do nothing - no file found
-		return
-	else:
-		# save the file
-		from webnotes.utils.file_manager import FileAttachments
-		
-		fa = FileAttachments('Profile', webnotes.session['user'])
-		fa.delete_all()
-		fa.add(uh.file_name, uh.content)
-		fa.save()
-		
-		uh.set_callback('window.parent.upload_callback("%s", "%s")' \
-		 	% (webnotes.form_dict['uploader_id'], fa.get_fid(0)))
+	from webnotes.utils.file_manager import add_file_list, remove_all
+	remove_all('Profile', webnotes.session['user'])
+	add_file_list('Profile', webnotes.session['user'], fname, fid)
diff --git a/erpnext/patches/deploy_email_digest.py b/erpnext/patches/deploy_email_digest.py
index 1dd97e3..02f842c 100644
--- a/erpnext/patches/deploy_email_digest.py
+++ b/erpnext/patches/deploy_email_digest.py
@@ -10,10 +10,31 @@
 	# Minor fix in print_format doctype
 	#reload_doc('core', 'doctype', 'print_format')
 	
-	reload_doc('setup', 'doctype', 'email_digest')
+	#reload_doc('setup', 'doctype', 'email_digest')
 
-	global create_default_email_digest
-	create_default_email_digest()
+	#global create_default_email_digest
+	#create_default_email_digest()
+
+	global enabled_default_email_digest
+	enabled_default_email_digest()
+
+
+def enabled_default_email_digest():
+	"""
+		Enables the created email digest
+	"""
+	from webnotes.model.doc import Document
+	from webnotes.model.code import get_obj
+	companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)
+	for company in companies_list:
+		if company and company[0]:
+			edigest = Document('Email Digest', 'Default Weekly Digest - ' + company[0])
+			if edigest:
+				edigest.enabled = 1
+				edigest.save()
+				ed_obj = get_obj(doc=edigest)
+				ed_obj.on_update()
+
 
 
 def create_default_email_digest():
diff --git a/index.html b/index.html
index 72b5ec2..a085f8c 100644
--- a/index.html
+++ b/index.html
@@ -3,7 +3,7 @@
 	<meta charset="utf-8">
 	<title>ERPNext</title>
 	<meta name="author" content="">
-	<script type="text/javascript">window._version_number="338"
+	<script type="text/javascript">window._version_number="340"
 
 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]={}}
diff --git a/versions-master.db b/versions-master.db
index 7175091..728c868 100644
--- a/versions-master.db
+++ b/versions-master.db
Binary files differ