Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/.gitignore b/.gitignore
index 62cc577..ba0a9a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,4 @@
 public/files
 public/backups
 public/css/wn-web.css
-public/js/wn-web.js
\ No newline at end of file
+public/js/wn-web.js
diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.txt b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.txt
index 88af72b..0dddb8a 100644
--- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.txt
+++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-04-13 11:56:18',
+		'creation': '2012-06-08 16:07:55',
 		'docstatus': 0,
-		'modified': '2012-06-07 19:05:06',
+		'modified': '2012-07-09 11:00:18',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -70,6 +70,17 @@
 	# DocField
 	{
 		'doctype': u'DocField',
+		'fieldname': u'customer_item_code',
+		'fieldtype': u'Data',
+		'hidden': 1,
+		'label': u"Customer's Item Code",
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
 		'fieldname': u'item_name',
 		'fieldtype': u'Data',
 		'in_filter': 0,
diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js
index c672aa1..4487c89 100644
--- a/erpnext/selling/doctype/opportunity/opportunity.js
+++ b/erpnext/selling/doctype/opportunity/opportunity.js
@@ -140,79 +140,8 @@
 	else 
 		return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
 }
-	
- //Fetch Item Details
-//====================================================================================================================
-cur_frm.cscript.item_code = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	if (d.item_code) {
-		get_server_fields('get_item_details',d.item_code,'enquiry_details',doc,cdt,cdn,1);
-	}
-}
 
-/*
- //Fetch Customer Details
-//======================================================================================================================
-cur_frm.cscript.customer = function(doc, cdt, cdn){
-	if (doc.customer) {
-		get_server_fields('get_cust_address',doc.customer,'',doc,cdt,cdn,1);
-	}
-}
-*/
-
-/*
-//=======================================================================================================================
-cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
-	return 'SELECT `tabContact`.contact_name FROM `tabContact` WHERE `tabContact`.is_customer = 1 AND `tabContact`.customer = "'+ doc.customer+'" AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
-}
-*/
-
-/*
-//=======================================================================================================================
-cur_frm.cscript.contact_person = function(doc, cdt, cdn){
-	if (doc.contact_person) {
-		arg = {};
-		arg.contact_person = doc.contact_person;
-		arg.customer = doc.customer;
-		get_server_fields('get_contact_details',docstring(arg),'',doc,cdt,cdn,1);
-	}
-}
-*/
-
-/*
-// hide - unhide fields based on lead or customer..
-//=======================================================================================================================
-cur_frm.cscript.clear_values = function(doc,cdt,cdn) {
-	if(doc.enquiry_from == 'Lead') {
-		doc.customer = doc.customer_name = doc.contact_person = doc.customer_group = "";
-	}
-	else if(doc.enquiry_from == 'Customer') {
-		doc.lead =	doc.lead_name = "";
-	}
-	refresh_many(['lead','lead_name','customer','customer_name','contact_person','customer_group']);
-}
-*/
-
-/*
-//================ hide - unhide fields on basis of enquiry from either lead or customer =============================== 
-cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
-	cur_frm.cscript.clear_values(doc,cdt,cdn);
-	 doc.address = doc.territory = doc.contact_no = doc.email_id = "";
-	 refresh_many(['territory','address','contact_no','email_id']);
-}
-*/
-
-/*
-//================ create new contact ============================================================================
-cur_frm.cscript.new_contact = function(){
-	tn = createLocal('Contact');
-	locals['Contact'][tn].is_customer = 1;
-	if(doc.customer) locals['Contact'][tn].customer = doc.customer;
-	loaddoc('Contact', tn);
-}
-*/
- // Create New Quotation
-// =======================================================================================================================
+// Create New Quotation
 cur_frm.cscript['Create Quotation'] = function(){
 	n = createLocal("Quotation");
 	$c('dt_map', args={
@@ -284,39 +213,5 @@
 }
 
 //get query select Territory
-//=======================================================================================================================
 cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
 	return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s"	ORDER BY	`tabTerritory`.`name` ASC LIMIT 50';}
-
-/*
-//===================== Opportunity From validation - either customer or lead is mandatory =====================================
-cur_frm.cscript.enq_frm_validate = function(doc,cdt,cdn){
-	
-	if(doc.enquiry_from == 'Lead'){
-		if(!doc.lead){
-			alert("Lead is mandatory.");	
-			validated = false; 
-		}
-	}
-	else if(doc.enquiry_from == 'Customer'){
-			if(!doc.customer){
-			alert("Customer is mandatory.");
-			validated = false;
-		}
-		else if(!doc.contact_person){
-			alert("Contact Person is mandatory.");
-			validated = false;
-		}
-		else if(!doc.customer_group){
-			alert("Customer Group is mandatory.");
-			validated = false;
-		}
-	} 
-}
-*/
-
-//===================validation function ==============================================================================
-
-cur_frm.cscript.validate = function(doc,cdt,cdn){
-	//cur_frm.cscript.enq_frm_validate(doc,cdt,cdn);
-}
diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.txt b/erpnext/selling/doctype/quotation_item/quotation_item.txt
index d5ece1f..6ae657c 100644
--- a/erpnext/selling/doctype/quotation_item/quotation_item.txt
+++ b/erpnext/selling/doctype/quotation_item/quotation_item.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-06-04 15:40:56',
+		'creation': '2012-06-08 16:07:57',
 		'docstatus': 0,
-		'modified': '2012-06-07 17:58:39',
+		'modified': '2012-07-09 11:04:47',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -63,6 +63,17 @@
 	# DocField
 	{
 		'doctype': u'DocField',
+		'fieldname': u'customer_item_code',
+		'fieldtype': u'Data',
+		'hidden': 1,
+		'label': u"Customer's Item Code",
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
 		'fieldname': u'item_name',
 		'fieldtype': u'Data',
 		'in_filter': 1,
diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py
index e146e91..74963fb 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.py
+++ b/erpnext/selling/doctype/sales_common/sales_common.py
@@ -163,6 +163,15 @@
 		if ret['warehouse'] or ret['reserved_warehouse']:
 			av_qty = self.get_available_qty({'item_code': args['item_code'], 'warehouse': ret['warehouse'] or ret['reserved_warehouse']})
 			ret.update(av_qty)
+			
+		# get customer code for given item from Item Customer Detail
+		customer_item_code_row = webnotes.conn.sql("""\
+			select ref_code from `tabItem Customer Detail`
+			where parent = %s and customer_name = %s""",
+			(args['item_code'], obj.doc.customer))
+		if customer_item_code_row and customer_item_code_row[0][0]:
+			ret['customer_item_code'] = customer_item_code_row[0][0]
+		
 		return ret
 
 
diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.txt b/erpnext/selling/doctype/sales_order_item/sales_order_item.txt
index 1d2f358..1c80698 100644
--- a/erpnext/selling/doctype/sales_order_item/sales_order_item.txt
+++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-04-13 11:56:28',
+		'creation': '2012-06-08 16:07:58',
 		'docstatus': 0,
-		'modified': '2012-06-07 18:04:52',
+		'modified': '2012-07-09 11:05:16',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -60,6 +60,17 @@
 	# DocField
 	{
 		'doctype': u'DocField',
+		'fieldname': u'customer_item_code',
+		'fieldtype': u'Data',
+		'hidden': 1,
+		'label': u"Customer's Item Code",
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
 		'fieldname': u'item_name',
 		'fieldtype': u'Data',
 		'label': u'Item Name',
diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py
index b0f0e9f..aff79f6 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.py
+++ b/erpnext/setup/doctype/email_digest/email_digest.py
@@ -255,7 +255,10 @@
 				args['sum_if_reqd'] = "IFNULL(SUM(IFNULL(%(sum_col)s, 0)), 0) AS '%(sum_col)s'," % args
 			
 			if args['type'] == 'new_transactions':
-				args['company_condition'] = ''
+				# tabFeed doesn't have company column
+				# using this arg to set condition of feed_type as null
+				# so that comments, logins and assignments are not counted
+				args['company_condition'] = "feed_type IS NULL AND"
 			else:
 				args['company_condition'] = "company = '%(company)s' AND" % args
 				
diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.txt b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.txt
index 5abb70d..8d0d387 100644
--- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.txt
+++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-04-13 11:56:35',
+		'creation': '2012-06-08 16:08:01',
 		'docstatus': 0,
-		'modified': '2012-06-07 17:57:14',
+		'modified': '2012-07-09 11:06:26',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -70,6 +70,17 @@
 
 	# DocField
 	{
+		'doctype': u'DocField',
+		'fieldname': u'customer_item_code',
+		'fieldtype': u'Data',
+		'hidden': 1,
+		'label': u"Customer's Item Code",
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
 		'colour': u'White:FFF',
 		'doctype': u'DocField',
 		'fieldname': u'item_name',
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index f0fb5e7..0f6cc4c 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -59,8 +59,7 @@
 			if cstr(d.uom) in check_list:
 				msgprint("UOM %s has been entered more than once in Conversion Factor Details." % cstr(d.uom))
 				raise Exception
-
-			if not cstr(d.uom) in check_list:
+			else:
 				check_list.append(cstr(d.uom))
 
 			if cstr(d.uom) == cstr(self.doc.stock_uom):
diff --git a/erpnext/utilities/cleanup_data.py b/erpnext/utilities/cleanup_data.py
new file mode 100644
index 0000000..60b54ec
--- /dev/null
+++ b/erpnext/utilities/cleanup_data.py
@@ -0,0 +1,201 @@
+#!/usr/bin/python
+
+# This script is for cleaning up of all data from system including 
+# all transactions and masters (excludes default masters). 
+# Basically after running this file, system will reset to it's 
+# initial state.
+# This script can be executed from lib/wnf.py using 
+# lib/wnf.py --cleanup-data
+
+import sys
+sys.path.append("lib/py")
+sys.path.append(".")
+sys.path.append("erpnext")
+
+import webnotes
+
+#--------------------------------
+
+def delete_transactions():
+	print "Deleting transactions..."
+
+	trans = ['Timesheet','Task','Support Ticket','Stock Reconciliation', 'Stock Ledger Entry', \
+		'Stock Entry','Sales Order','Salary Slip','Sales Invoice','Quotation', 'Quality Inspection', \
+		'Purchase Receipt','Purchase Order','Production Order', 'POS Setting','Period Closing Voucher', \
+		'Purchase Invoice','Maintenance Visit','Maintenance Schedule','Leave Application', \
+		'Leave Allocation', 'Lead', 'Journal Voucher', 'Installation Note','Purchase Request', \
+		'GL Entry','Expense Claim','Opportunity','Delivery Note','Customer Issue','Bin', \
+		'Authorization Rule','Attendance','Account Balance', 'C-Form', 'Form 16A', 'Lease Agreement', \
+		'Lease Installment', 'TDS Payment', 'TDS Return Acknowledgement', 'Appraisal', \
+		'Installation Note', 'Communication'
+	]
+	for d in trans:
+		for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d):
+			webnotes.conn.sql("delete from `tab%s`" % (t))
+		webnotes.conn.sql("delete from `tab%s`" % (d))
+		webnotes.conn.sql("COMMIT")
+		webnotes.conn.sql("START TRANSACTION")
+		print "Deleted " + d
+	
+	
+	
+def delete_masters():
+	print "Deleting masters...."
+	masters = {
+		'Workstation':['Default Workstation'],
+		'Warehouse Type':['Default Warehouse Type', 'Fixed Asset', 'Rejected', 'Reserved', 
+			'Sample', 'Stores', 'WIP Warehouse'],
+		'Warehouse':['Default Warehouse'],
+		'UOM':['Kg', 'Mtr', 'Box', 'Ltr', 'Nos', 'Ft', 'Pair', 'Set'],
+		'Territory':['All Territories', 'Default Territory'],
+		'Terms and Conditions':'',
+		'Tag':'',
+		'Supplier Type':['Default Supplier Type'],
+		'Supplier':'',
+		'Serial No':'',
+		'Sales Person':['All Sales Persons'],
+		'Sales Partner':'',
+		'Sales BOM':'',
+		'Salary Structure':'',
+		'Purchase Taxes and Charges Master':'',
+		'Project':'',
+		'Print Heading':'',
+		'Price List':['Default Price List'],
+		'Period':'',
+		'Sales Taxes and Charges Master':'',
+		'Letter Head':'',
+		'Leave Type':['Leave Without Pay', 'Privilege Leave', 'Casual Leave', 'PL', 'CL', 'LWP', 
+			'Compensatory Off', 'Sick Leave'],
+		'Landed Cost Master':'',
+		'Appraisal Template':'',
+		'Item Group':['All Item Groups', 'Default'], 
+		'Item':'',
+		'Holiday List':'',
+		'Grade':'',
+		'Feed':'',
+		'Expense Claim Type':['Travel', 'Medical', 'Calls', 'Food', 'Others'],
+		'Event':'', 
+		'Employment Type':'', 
+		'Employee':'',
+		'Earning Type':['Basic', 'Conveyance', 'House Rent Allowance', 'Dearness Allowance', 
+			'Medical Allowance', 'Telephone'],
+		'Designation':'',
+		'Department':'',
+		'Deduction Type':['Income Tax', 'Professional Tax', 'Provident Fund', 'Leave Deduction'],
+		'Customer Group':['All Customer Groups', 'Default Customer Group'],
+		'Customer':'',
+		'Cost Center':'', 
+		'Contact':'',
+		'Campaign':'', 
+		'Budget Distribution':'', 
+		'Brand':'',
+		'Branch':'',
+		'Batch':'', 
+		'Appraisal':'', 
+		'Account':'', 
+		'BOM': ''
+	}
+	for d in masters.keys():
+		for t in webnotes.conn.sql("select options from tabDocField where parent='%s' \
+			and fieldtype='Table'" % d):
+			webnotes.conn.sql("delete from `tab%s`" % (t))
+		lst = '"'+'","'.join(masters[d])+ '"'
+		webnotes.conn.sql("delete from `tab%s` where name not in (%s)" % (d, lst))
+		webnotes.conn.sql("COMMIT")
+		webnotes.conn.sql("START TRANSACTION")
+		print "Deleted " + d
+
+
+
+def reset_series():
+	# Reset series
+	webnotes.conn.sql("""update tabSeries set current = 0 where name not in \
+		('Ann/', 'BSD', 'DEF', 'DF', 'EV', 'Event Updates/', 'FileData-', \
+		'FL', 'FMD/', 'GLM Detail', 'Login Page/', 'MDI', 'MDR', 'MI', 'MIR', \
+		'PERM', 'PR', 'SRCH/C/', 'TD', 'TIC/', 'TMD/', 'TW', 'UR', '_FEED', \
+		'_SRCH', '_TRIGGER', '__NSO', 'CustomField', 'Letter')
+	""")
+	print "Series updated"
+
+
+def delete_main_masters():
+	main_masters = ['Fiscal Year','Company', 'DefaultValue']
+	for d in main_masters:
+		for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d):
+			webnotes.conn.sql("delete from `tab%s`" % (t))
+		webnotes.conn.sql("delete from `tab%s`" % (d))
+		webnotes.conn.sql("COMMIT")
+		webnotes.conn.sql("START TRANSACTION")
+		print "Deleted " + d
+	
+
+
+def reset_global_defaults():
+	flds = {
+		'default_company': '', 
+		'default_currency': '', 
+		'default_currency_format': 'Lacs', 
+		'default_currency_fraction': '', 
+		'current_fiscal_year': '', 
+		'date_format': 'dd-mm-yyyy', 
+		'sms_sender_name': '', 
+		'default_item_group': 'Default', 
+		'default_stock_uom': 'Nos', 
+		'default_valuation_method': 'FIFO', 
+		'default_warehouse_type': 'Default Warehouse Type', 
+		'tolerance': '', 
+		'acc_frozen_upto': '', 
+		'bde_auth_role': '', 
+		'credit_controller': '', 
+		'default_customer_group': 'Default Customer Group', 
+		'default_territory': 'Default', 
+		'default_price_list': 'Standard', 
+		'default_supplier_type': 'Default Supplier Type'
+	}
+
+	from webnotes.model.code import get_obj
+	gd = get_obj('Global Defaults', 'Global Defaults')
+	for d in flds:
+		gd.doc.fields[d] = flds[d]
+	gd.doc.save()
+	
+	webnotes.clear_cache()
+
+
+def run():
+	webnotes.connect()
+	
+	# Confirmation from user
+	confirm = ''
+	while not confirm:
+		confirm = raw_input("Are you sure you want to delete the data from the system (N/Y)?")
+	if confirm.lower() != 'y':
+		raise Exception
+
+	cleanup_type = ''
+	while cleanup_type not in ['1', '2']:
+		cleanup_type = raw_input("""\nWhat type of cleanup you want ot perform?
+	1. Only Transactions
+	2. Both Masters and Transactions
+
+	Please enter your choice (1/2):
+		""")
+		
+	# delete
+	delete_transactions()
+	
+	if cleanup_type == '1':	
+		print '\n', '*' * 10 + 'NOTE' + '*' * 10, '\n'
+		print "To reset series of the transactions go to Setup --> Numbering Series\n"
+	else:
+		delete_masters()
+		reset_series()
+		delete_main_masters()
+		reset_global_defaults()
+
+	print "System cleaned up succesfully"
+	webnotes.conn.close()
+
+
+if __name__ == '__main__':
+	run()
diff --git a/erpnext/utilities/page/questions/questions.js b/erpnext/utilities/page/questions/questions.js
index 33e0853..048ed54 100644
--- a/erpnext/utilities/page/questions/questions.js
+++ b/erpnext/utilities/page/questions/questions.js
@@ -14,8 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-pscript.onload_questions = function(wrapper) {	
-	console.log(1);
+pscript.onload_questions = function(wrapper) {
 	body = $(wrapper).find('.layout-main-section').get(0);
 	
 	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe'));
diff --git a/erpnext/utilities/page/todo/todo.css b/erpnext/utilities/page/todo/todo.css
index ee9b4f1..7c7dcaf 100644
--- a/erpnext/utilities/page/todo/todo.css
+++ b/erpnext/utilities/page/todo/todo.css
@@ -47,4 +47,9 @@
 
 .todo-content {
 	padding-right: 15px;
+}
+
+.layout-main {
+	background-color: #FFFDC9;
+	min-height: 300px;
 }
\ No newline at end of file
diff --git a/erpnext/utilities/page/todo/todo.html b/erpnext/utilities/page/todo/todo.html
index d49fc23..88dcbf3 100644
--- a/erpnext/utilities/page/todo/todo.html
+++ b/erpnext/utilities/page/todo/todo.html
@@ -1,9 +1,6 @@
-<div class="layout-wrapper" style="min-height: 300px; background-color: #FFFDC9">
+<div class="layout-wrapper layout-wrapper-background">
 	<div class="appframe-area"></div>
-	<div>
-		<a class="close" onclick="window.history.back();">&times;</a>
-		<h1>To Do</h1>
-		<br>
+	<div class="layout-main">
 		<div>
 			<div id="todo-list">
 				<h4>My List</h4><br>
@@ -14,8 +11,6 @@
 				<div class="todo-content"></div>
 			</div>
 		</div>
-		<div style="margin-top: 21px; clear: both">
-			<button id="add-todo" class="btn btn-small"><i class="icon-plus"></i> Add</button>
-		</div>
+		<div style="clear: both"></div>
 	</div>
 </div>
\ No newline at end of file
diff --git a/erpnext/utilities/page/todo/todo.js b/erpnext/utilities/page/todo/todo.js
index 206becf..786e757 100644
--- a/erpnext/utilities/page/todo/todo.js
+++ b/erpnext/utilities/page/todo/todo.js
@@ -48,11 +48,6 @@
 			}
 		}
 	});
-	
-	$('#add-todo').click(function() {
-		erpnext.todo.make_dialog({
-			date:get_today(), priority:'Medium', checked:0, description:''});
-	})
 }
 
 erpnext.todo.ToDoItem = Class.extend({
@@ -196,7 +191,15 @@
 	});
 }
 
-wn.pages.todo.onload = function() {
+wn.pages.todo.onload = function(wrapper) {
+	// create app frame
+	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'), 'To Do');
+	wrapper.appframe.add_button('Refresh', erpnext.todo.refresh, 'icon-refresh');
+	wrapper.appframe.add_button('Add', function() {
+		erpnext.todo.make_dialog({
+			date:get_today(), priority:'Medium', checked:0, description:''});
+	}, 'icon-plus');
+
 	// load todos
 	erpnext.todo.refresh();
 }
\ No newline at end of file
diff --git a/public/css/all-app.css b/public/css/all-app.css
index 93dfe47..ecdbe65 100644
--- a/public/css/all-app.css
+++ b/public/css/all-app.css
@@ -3219,6 +3219,8 @@
 	height: 18px;
 	border: 1px solid #aaa;
 	border-radius: 9px;
+	-webkit-border-radius: 9px;
+	-moz-border-radius: 9px;
 	overflow: hidden;
 }
 
@@ -3227,6 +3229,10 @@
 	left: 0px;
 	height: 100%;
 	z-index: 0;
+	/* So that this div is also curved like the enclosing one */
+	border-radius: 9px;
+	-webkit-border-radius: 9px;
+	-moz-border-radius: 9px;
 
 	background: #e0ff84; /* Old browsers */
 	background: -moz-linear-gradient(top,  #e0ff84 0%, #a4e567 100%); /* FF3.6+ */
diff --git a/public/css/all-web.css b/public/css/all-web.css
index a2de6b6..332471b 100644
--- a/public/css/all-web.css
+++ b/public/css/all-web.css
@@ -2470,6 +2470,8 @@
 	height: 18px;
 	border: 1px solid #aaa;
 	border-radius: 9px;
+	-webkit-border-radius: 9px;
+	-moz-border-radius: 9px;
 	overflow: hidden;
 }
 
@@ -2478,6 +2480,10 @@
 	left: 0px;
 	height: 100%;
 	z-index: 0;
+	/* So that this div is also curved like the enclosing one */
+	border-radius: 9px;
+	-webkit-border-radius: 9px;
+	-moz-border-radius: 9px;
 
 	background: #e0ff84; /* Old browsers */
 	background: -moz-linear-gradient(top,  #e0ff84 0%, #a4e567 100%); /* FF3.6+ */
diff --git a/public/js/all-app.js b/public/js/all-app.js
index 569b17d..bad3f9e 100644
--- a/public/js/all-app.js
+++ b/public/js/all-app.js
@@ -1823,7 +1823,7 @@
 if(doctype.client_string){this.cstring={};var elist=doctype.client_string.split('---');for(var i=1;i<elist.length;i=i+2){this.cstring[strip(elist[i])]=elist[i+1];}}}
 return ret;}
 _f.Frm.prototype.copy_doc=function(onload,from_amend){if(!this.perm[0][CREATE]){msgprint('You are not allowed to create '+this.meta.name);return;}
-var dn=this.docname;var newdoc=LocalDB.copy(this.doctype,dn,from_amend);if(this.meta.allow_attach&&newdoc.file_list)
+var dn=this.docname;var newdoc=LocalDB.copy(this.doctype,dn,from_amend);if(this.meta.allow_attach&&newdoc.file_list&&!from_amend)
 newdoc.file_list=null;var dl=make_doclist(this.doctype,dn);var tf_dict={};for(var d in dl){d1=dl[d];if(!tf_dict[d1.parentfield]){tf_dict[d1.parentfield]=get_field(d1.parenttype,d1.parentfield);}
 if(d1.parent==dn&&cint(tf_dict[d1.parentfield].no_copy)!=1){var ch=LocalDB.copy(d1.doctype,d1.name,from_amend);ch.parent=newdoc.name;ch.docstatus=0;ch.owner=user;ch.creation='';ch.modified_by=user;ch.modified='';}}
 newdoc.__islocal=1;newdoc.docstatus=0;newdoc.owner=user;newdoc.creation='';newdoc.modified_by=user;newdoc.modified='';if(onload)onload(newdoc);loaddoc(newdoc.doctype,newdoc.name);}