[fix] [minor] merge conflict fixed
diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py
index 1f2d060..992c4dc 100644
--- a/accounts/doctype/account/account.py
+++ b/accounts/doctype/account/account.py
@@ -192,41 +192,40 @@
 			
 		if self.check_gle_exists():
 			msgprint("""Account with existing transaction (Sales Invoice / Purchase Invoice / \
-				Journal Voucher) can not be trashed""", raise_exception=1)
+				Journal Voucher) can not be deleted""", raise_exception=1)
 		if self.check_if_child_exists():
-			msgprint("Child account exists for this account. You can not trash this account.",
+			msgprint("Child account exists for this account. You can not delete this account.",
 			 	raise_exception=1)
 
 	def on_trash(self): 
 		self.validate_trash()
 		self.update_nsm_model()
-
-	def on_rename(self, new, old, merge=False):
-		company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")		
-		parts = new.split(" - ")	
-
-		if parts[-1].lower() != company_abbr.lower():
-			parts.append(company_abbr)
 		
-		# rename account name
-		new_account_name = " - ".join(parts[:-1])
-		webnotes.conn.sql("update `tabAccount` set account_name = %s where name = %s", (new_account_name, old))
+	def before_rename(self, old, new, merge=False):
+		# Add company abbr if not provided
+		from setup.doctype.company.company import get_name_with_abbr
+		new_account = get_name_with_abbr(new, self.doc.company)
 		
+		# Validate properties before merging
 		if merge:
-			new_name = " - ".join(parts)
-			val = list(webnotes.conn.get_value("Account", new_name, 
+			val = list(webnotes.conn.get_value("Account", new_account, 
 				["group_or_ledger", "debit_or_credit", "is_pl_account"]))
 			
 			if val != [self.doc.group_or_ledger, self.doc.debit_or_credit, self.doc.is_pl_account]:
-				msgprint(_("""Merging is only possible if following \
+				webnotes.throw(_("""Merging is only possible if following \
 					properties are same in both records.
-					Group or Ledger, Debit or Credit, Is PL Account"""), raise_exception=1)
+					Group or Ledger, Debit or Credit, Is PL Account"""))
+					
+		return new_account
 
+	def after_rename(self, old, new, merge=False):
+		if not merge:
+			webnotes.conn.set_value("Account", new, "account_name", 
+				" - ".join(new.split(" - ")[:-1]))
+		else:
 			from webnotes.utils.nestedset import rebuild_tree
 			rebuild_tree("Account", "parent_account")
 
-		return " - ".join(parts)
-
 def get_master_name(doctype, txt, searchfield, start, page_len, filters):
 	conditions = (" and company='%s'"% filters["company"]) if doctype == "Warehouse" else ""
 		
diff --git a/accounts/doctype/cost_center/cost_center.py b/accounts/doctype/cost_center/cost_center.py
index 4900edd..692d47e 100644
--- a/accounts/doctype/cost_center/cost_center.py
+++ b/accounts/doctype/cost_center/cost_center.py
@@ -16,7 +16,7 @@
 	def autoname(self):
 		company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s", 
 			self.doc.company)[0][0]
-		self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr		
+		self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr
 		
 	def validate_mandatory(self):
 		if not self.doc.group_or_ledger:
@@ -73,18 +73,20 @@
 		self.validate_mandatory()
 		self.validate_budget_details()
 		
-	def on_rename(self, new, old, merge=False):
-		company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")		
-		parts = new.split(" - ")	
-
-		if parts[-1].lower() != company_abbr.lower():
-			parts.append(company_abbr)
-
-		# rename account name
-		cost_center_name = " - ".join(parts[:-1])
-		webnotes.conn.sql("update `tabCost Center` set cost_center_name = %s where name = %s", \
-			(cost_center_name, old))
+	def before_rename(self, olddn, newdn, merge=False):
+		# Add company abbr if not provided
+		from setup.doctype.company.company import get_name_with_abbr
+		new_cost_center = get_name_with_abbr(newdn, self.doc.company)
+		
+		# Validate properties before merging
+		super(DocType, self).before_rename(olddn, new_cost_center, merge, "group_or_ledger")
+		
+		return new_cost_center
+		
+	def after_rename(self, olddn, newdn, merge=False):
+		if not merge:
+			webnotes.conn.set_value("Cost Center", newdn, "cost_center_name", 
+				" - ".join(newdn.split(" - ")[:-1]))
+		else:
+			super(DocType, self).after_rename(olddn, newdn, merge)
 			
-		super(DocType, self).on_rename(new, old, merge, "group_or_ledger")
-
-		return " - ".join(parts)	
diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
index e8333cb..e1a0d14 100644
--- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
+++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
@@ -29,6 +29,11 @@
     var new_val = flt(val)/flt(doc.conversion_rate);
     return new_val;
   }
+  
+  function print_hide(fieldname) {
+	var doc_field = wn.meta.get_docfield(doc.doctype, fieldname, doc.name);
+	return doc_field.print_hide;
+  }
 
   var cl = getchildren('Purchase Taxes and Charges',doc.name,'purchase_tax_details');
 
@@ -38,18 +43,21 @@
   
   // main table
   out +='<table class="noborder" style="width:100%">'
-		+make_row('Net Total',convert_rate(doc.net_total),1);
-
+  if(!print_hide('net_total')) {
+	out += make_row('Net Total', convert_rate(doc.net_total), 1);
+  }
+  
   // add rows
   if(cl.length){
     for(var i=0;i<cl.length;i++){
       out += make_row(cl[i].description,convert_rate(cl[i].tax_amount),0);
     }
   }
-  
-  // grand total
-  out +=make_row('Grand Total',doc.grand_total_import,1)
-  if(doc.in_words_import){
+	// grand total
+	if(!print_hide('grand_total_import')) {
+		out += make_row('Grand Total', doc.grand_total_import, 1);
+	}
+  if(doc.in_words_import && !print_hide('in_words_import')){
     out +='</table></td></tr>';
     out += '<tr><td colspan = "2">';
     out += '<table><tr><td style="width:25%;"><b>In Words</b></td>';
diff --git a/accounts/report/accounts_receivable/accounts_receivable.py b/accounts/report/accounts_receivable/accounts_receivable.py
index 40f4d2a..ad0d925 100644
--- a/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/accounts/report/accounts_receivable/accounts_receivable.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
@@ -19,12 +19,13 @@
 		
 	def get_columns(self):
 		return [
-			"Posting Date:Date:80", "Account:Link/Account:150", "Customer::150", 
-			"Voucher Type::110", "Voucher No::120", "Remarks::150", 
-			"Due Date:Date:80", "Territory:Link/Territory:80", 
+			"Posting Date:Date:80", "Account:Link/Account:150",
+			"Voucher Type::110", "Voucher No::120", "::30",
+			"Due Date:Date:80",  
 			"Invoiced Amount:Currency:100", "Payment Received:Currency:100", 
 			"Outstanding Amount:Currency:100", "Age:Int:50", "0-30:Currency:100",
-			"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100"
+			"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100",
+			"Customer:Link/Customer:200", "Territory:Link/Territory:80", "Remarks::200"
 		]
 		
 	def get_data(self):
@@ -37,14 +38,20 @@
 					due_date = self.get_due_date(gle)
 					invoiced_amount = gle.debit if (gle.debit > 0) else 0
 					payment_received = invoiced_amount - outstanding_amount
-					row = [gle.posting_date, gle.account, self.get_customer(gle.account),
-						gle.voucher_type, gle.voucher_no, gle.remarks, due_date,
-						self.get_territory(gle.account), invoiced_amount, payment_received,
+					row = [gle.posting_date, gle.account,
+						gle.voucher_type, gle.voucher_no, due_date,
+						invoiced_amount, payment_received,
 						outstanding_amount]
 					entry_date = due_date if self.filters.ageing_based_on=="Due Date" \
 						else gle.posting_date
 					row += get_ageing_data(self.age_as_on, entry_date, outstanding_amount)
+					row += [self.get_customer(gle.account), self.get_territory(gle.account), gle.remarks]
 					data.append(row)
+		
+		for i in range(0,len(data)):
+			data[i].insert(4, """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
+				% ("/".join(["#Form", data[i][2], data[i][3]]),))
+		
 		return data
 				
 	def get_entries_after(self, report_date):
@@ -157,4 +164,4 @@
 	if index is None: index = 3
 	outstanding_range[index] = outstanding_amount
 	
-	return [age] + outstanding_range
\ No newline at end of file
+	return [age] + outstanding_range
diff --git a/accounts/report/budget_variance_report/budget_variance_report.py b/accounts/report/budget_variance_report/budget_variance_report.py
index 1f426c0..2cbbd62 100644
--- a/accounts/report/budget_variance_report/budget_variance_report.py
+++ b/accounts/report/budget_variance_report/budget_variance_report.py
@@ -73,10 +73,10 @@
 def get_target_distribution_details(filters):
 	target_details = {}
 
-	for d in webnotes.conn.sql("""select bd.name, bdd.month, bdd.percentage_allocation \
+	for d in webnotes.conn.sql("""select bd.name, bdd.month, bdd.percentage_allocation  
 		from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
 		where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
-			target_details.setdefault(d.name, {}).setdefault(d.month, d.percentage_allocation)
+			target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
 
 	return target_details
 
@@ -113,10 +113,11 @@
 				}))
 
 			tav_dict = cam_map[ccd.name][ccd.account][month]
-			month_percentage = ccd.distribution_id and \
-				tdd.get(ccd.distribution_id, {}).get(month, 0) or 100.0/12
+
+			month_percentage = tdd.get(ccd.distribution_id, {}).get(month, 0) \
+				if ccd.distribution_id else 100.0/12
 				
-			tav_dict.target = flt(ccd.budget_allocated) * month_percentage /100
+			tav_dict.target = flt(ccd.budget_allocated) * month_percentage / 100
 			
 			for ad in actual_details.get(ccd.name, {}).get(ccd.account, []):
 				if ad.month_name == month:
diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js
index a0bac3f..dad2864 100644
--- a/buying/doctype/purchase_order/purchase_order.js
+++ b/buying/doctype/purchase_order/purchase_order.js
@@ -23,8 +23,8 @@
 			cur_frm.dashboard.add_progress(cint(doc.per_billed) + wn._("% Billed"), 
 				doc.per_billed);
 
+			cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
 
-			cur_frm.appframe.add_button(wn._('Send SMS'), cur_frm.cscript['Send SMS'], "icon-mobile-phone");
 			if(flt(doc.per_received, 2) < 100) 
 				cur_frm.add_custom_button(wn._('Make Purchase Receipt'), this.make_purchase_receipt);	
 			if(flt(doc.per_billed, 2) < 100) 
diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py
index 46abe89..f60d4dd 100644
--- a/buying/doctype/supplier/supplier.py
+++ b/buying/doctype/supplier/supplier.py
@@ -148,29 +148,21 @@
 		self.delete_supplier_contact()
 		self.delete_supplier_account()
 		
-	def on_rename(self, new, old, merge=False):
+	def after_rename(self, old, new, merge=False):
 		#update supplier_name if not naming series
 		if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name':
-			update_fields = [
-			('Supplier', 'name'),
-			('Address', 'supplier'),
-			('Contact', 'supplier'),
-			('Purchase Invoice', 'supplier'),
-			('Purchase Order', 'supplier'),
-			('Purchase Receipt', 'supplier'),
-			('Serial No', 'supplier')]
-			for rec in update_fields:
-				webnotes.conn.sql("update `tab%s` set supplier_name = %s where `%s` = %s" % \
-					(rec[0], '%s', rec[1], '%s'), (new, old))
+			webnotes.conn.set(self.doc, "supplier_name", new)
 				
 		for account in webnotes.conn.sql("""select name, account_name from 
 			tabAccount where master_name=%s and master_type='Supplier'""", old, as_dict=1):
 			if account.account_name != new:
-				webnotes.rename_doc("Account", account.name, new, merge=merge)
+				merge_account = True if merge and webnotes.conn.get_value("Account", 
+					{"master_name": new, "master_type": "Supplier"}) else False
+				webnotes.rename_doc("Account", account.name, new, merge=merge_account)
 
 		#update master_name in doctype account
 		webnotes.conn.sql("""update `tabAccount` set master_name = %s, 
-			master_type = 'Supplier' where master_name = %s""" , (new,old))
+			master_type = 'Supplier' where master_name = %s""" , (new, old))
 
 @webnotes.whitelist()
 def get_dashboard_info(supplier):
diff --git a/buying/utils.py b/buying/utils.py
index a0c150d..0d9c8fa 100644
--- a/buying/utils.py
+++ b/buying/utils.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import webnotes
 from webnotes import msgprint, _
-from webnotes.utils import getdate, flt, add_days
+from webnotes.utils import getdate, flt, add_days, cstr
 import json
 
 @webnotes.whitelist()
@@ -94,7 +94,6 @@
 			(args.buying_price_list, args.item_code), as_dict=1)
 		
 		if price_list_rate:
-			from utilities.transaction_base import validate_currency
 			validate_currency(args, item_bean.doc, meta)
 				
 			out.import_ref_rate = flt(price_list_rate[0].ref_rate) * \
@@ -132,7 +131,7 @@
 			_("Please select a sub-contracted item or do not sub-contract the transaction."), 
 			raise_exception=True)
 
-def get_last_purchase_details(item_code, doc_name, conversion_rate=1.0):
+def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
 	"""returns last purchase details in stock uom"""
 	# get last purchase order item details
 	last_purchase_order = webnotes.conn.sql("""\
@@ -143,7 +142,7 @@
 		where po.docstatus = 1 and po_item.item_code = %s and po.name != %s and 
 			po.name = po_item.parent
 		order by po.transaction_date desc, po.name desc
-		limit 1""", (item_code, doc_name), as_dict=1)
+		limit 1""", (item_code, cstr(doc_name)), as_dict=1)
 
 	# get last purchase receipt item details		
 	last_purchase_receipt = webnotes.conn.sql("""\
@@ -154,7 +153,7 @@
 		where pr.docstatus = 1 and pr_item.item_code = %s and pr.name != %s and
 			pr.name = pr_item.parent
 		order by pr.posting_date desc, pr.posting_time desc, pr.name desc
-		limit 1""", (item_code, doc_name), as_dict=1)
+		limit 1""", (item_code, cstr(doc_name)), as_dict=1)
 
 	purchase_order_date = getdate(last_purchase_order and last_purchase_order[0].transaction_date \
 		or "1900-01-01")
diff --git a/controllers/stock_controller.py b/controllers/stock_controller.py
index 1e3f3ae..8a4a402 100644
--- a/controllers/stock_controller.py
+++ b/controllers/stock_controller.py
@@ -48,7 +48,7 @@
 							"against": detail.expense_account,
 							"cost_center": detail.cost_center,
 							"remarks": self.doc.remarks or "Accounting Entry for Stock",
-							"debit": sle.stock_value_difference
+							"debit": flt(sle.stock_value_difference, 2)
 						}))
 
 						# to target warehouse / expense account
@@ -57,7 +57,7 @@
 							"against": warehouse_account[sle.warehouse],
 							"cost_center": detail.cost_center,
 							"remarks": self.doc.remarks or "Accounting Entry for Stock",
-							"credit": sle.stock_value_difference
+							"credit": flt(sle.stock_value_difference, 2)
 						}))
 					elif sle.warehouse not in warehouse_with_no_account:
 						warehouse_with_no_account.append(sle.warehouse)
diff --git a/hr/doctype/job_applicant/get_job_applications.py b/hr/doctype/job_applicant/get_job_applications.py
index 213a78a..33e1261 100644
--- a/hr/doctype/job_applicant/get_job_applications.py
+++ b/hr/doctype/job_applicant/get_job_applications.py
@@ -36,7 +36,7 @@
 		
 		mail.save_attachments_in_doc(applicant.doc)
 				
-		make(content=mail.content, sender=mail.from_email, 
+		make(content=mail.content, sender=mail.from_email, subject=mail.subject or "No Subject",
 			doctype="Job Applicant", name=applicant.doc.name, sent_or_received="Received")
 
 def get_job_applications():
diff --git a/patches/1311/p04_update_comments.py b/patches/1311/p04_update_comments.py
new file mode 100644
index 0000000..aefb7e7
--- /dev/null
+++ b/patches/1311/p04_update_comments.py
@@ -0,0 +1,8 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+def execute():
+	import webnotes
+	for name in webnotes.conn.sql_list("""select name from tabComment"""):
+		webnotes.get_obj("Comment", name).update_comment_in_doc()
+	
\ No newline at end of file
diff --git a/patches/1311/p05_website_brand_html.py b/patches/1311/p05_website_brand_html.py
new file mode 100644
index 0000000..04d2f83
--- /dev/null
+++ b/patches/1311/p05_website_brand_html.py
@@ -0,0 +1,16 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def execute():
+	bean = webnotes.bean("Website Settings")
+	for company in webnotes.conn.sql_list("select name from `tabCompany`"):
+		if bean.doc.banner_html == ("""<h3 style='margin-bottom: 20px;'>""" + company + "</h3>"):
+			bean.doc.banner_html = None
+			if not bean.doc.brand_html:
+				bean.doc.brand_html = company
+
+			bean.save()
+			break
\ No newline at end of file
diff --git a/patches/october_2013/p01_fix_serial_no_status.py b/patches/october_2013/p01_fix_serial_no_status.py
index f523845..4f00b27 100644
--- a/patches/october_2013/p01_fix_serial_no_status.py
+++ b/patches/october_2013/p01_fix_serial_no_status.py
@@ -11,7 +11,6 @@
 		try:
 			sr_bean = webnotes.bean("Serial No", sr[0])
 			sr_bean.make_controller().via_stock_ledger = True
-			sr_bean.run_method("validate")
 			sr_bean.save()
 			webnotes.conn.commit()
 		except:
diff --git a/patches/patch_list.py b/patches/patch_list.py
index abe96f9..d09cec1 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -245,10 +245,12 @@
 	"execute:webnotes.reload_doc('core', 'doctype', 'comment') #2013-11-15",
 	"patches.1311.p02_index_singles",
 	"patches.1311.p01_make_gl_entries_for_si",
-    "patches.1311.p03_update_reqd_report_fields",
+	"patches.1311.p03_update_reqd_report_fields",
 	"execute:webnotes.reload_doc('website', 'doctype', 'website_sitemap_config') #2013-11-20",
 	"execute:webnotes.reload_doc('website', 'doctype', 'website_sitemap') #2013-11-20",
 	"execute:webnotes.bean('Style Settings').save() #2013-11-20",
     "execute:webnotes.get_module('website.doctype.website_sitemap_config.website_sitemap_config').rebuild_website_sitemap_config()",
     "patches.1311.p04_update_year_end_date_of_fiscal_year",
+	"patches.1311.p04_update_comments",
+	"patches.1311.p05_website_brand_html",
 ]
\ No newline at end of file
diff --git a/portal/templates/includes/footer.html b/portal/templates/includes/footer.html
index 6963175..cd75fd1 100644
--- a/portal/templates/includes/footer.html
+++ b/portal/templates/includes/footer.html
@@ -1,16 +1,18 @@
 {% extends "lib/website/templates/includes/footer.html" %}
 
-{% block powered %}<a style="font-size: 90%; color: #aaa;" href="http://erpnext.org">ERPNext Powered</a>{% endblock %}
+{% block powered %}<a href="http://erpnext.org" style="color: #aaa;">ERPNext Powered</a>{% endblock %}
 
 {% block extension %}
-<br>
-<div class="input-group col-md-6 col-md-offset-3">
-	<input class="form-control" type="text" id="footer-subscribe-email" placeholder="Your email address...">
-	<span class="input-group-btn">
-		<button class="btn btn-default" type="button" id="footer-subscribe-button">Stay Updated</button>
-	</span>
+<div class="container">
+	<div class="row">
+		<div class="input-group col-sm-6 col-sm-offset-3" style="margin-top: 7px;">
+			<input class="form-control" type="text" id="footer-subscribe-email" placeholder="Your email address...">
+			<span class="input-group-btn">
+				<button class="btn btn-default" type="button" id="footer-subscribe-button">Stay Updated</button>
+			</span>
+		</div>
+	</div>
 </div>
-<br>
 <script>
 	$("#footer-subscribe-button").click(function() {
 
diff --git a/portal/templates/includes/transactions.html b/portal/templates/includes/transactions.html
index 036a77c..6148f18 100644
--- a/portal/templates/includes/transactions.html
+++ b/portal/templates/includes/transactions.html
@@ -1,7 +1,7 @@
 {% extends base_template %}
 
 {% block content -%}
-<div class="col-md-12">
+<div class="container content">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a></li>
     	<li class="active"><i class="{{ icon }} icon-fixed-width"></i> {{ title }}</li>
diff --git a/portal/templates/pages/cart.html b/portal/templates/pages/cart.html
index 8b648e5..1abe467 100644
--- a/portal/templates/pages/cart.html
+++ b/portal/templates/pages/cart.html
@@ -7,7 +7,7 @@
 {% set title="Shopping Cart" %}
 
 {% block content %}
-<div class="col-md-12">
+<div class="container content">
 	<h2><i class="icon-shopping-cart"></i> {{ title }}</h2>
 	<div class="progress progress-striped active">
 		<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
diff --git a/portal/templates/pages/profile.html b/portal/templates/pages/profile.html
index fe9ded5..a807731 100644
--- a/portal/templates/pages/profile.html
+++ b/portal/templates/pages/profile.html
@@ -3,7 +3,7 @@
 {% set title="My Profile" %}
 
 {% block content %}
-<div class="col-md-12">
+<div class="container content">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a></li>
     	<li class="active"><i class="icon-user icon-fixed-width"></i> My Profile</li>
diff --git a/portal/templates/sale.html b/portal/templates/sale.html
index 2a7c603..5dc72c7 100644
--- a/portal/templates/sale.html
+++ b/portal/templates/sale.html
@@ -3,7 +3,7 @@
 {% set title=doc.name %}
 
 {% block content %}
-<div class="col-md-12">
+<div class="container content">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a></li>
     	<li><a href="{{ parent_link }}">{{ parent_title }}</a></li>
diff --git a/public/js/stock_analytics.js b/public/js/stock_analytics.js
index a6314bb..832cac5 100644
--- a/public/js/stock_analytics.js
+++ b/public/js/stock_analytics.js
@@ -11,7 +11,7 @@
 			parent: $(wrapper).find('.layout-main'),
 			appframe: wrapper.appframe,
 			doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", 
-				"Fiscal Year"],
+				"Fiscal Year", "Serial No"],
 			tree_grid: {
 				show: true, 
 				parent_field: "parent_item_group", 
diff --git a/public/js/stock_grid_report.js b/public/js/stock_grid_report.js
index 414fd1b..b727123 100644
--- a/public/js/stock_grid_report.js
+++ b/public/js/stock_grid_report.js
@@ -14,7 +14,7 @@
 		// value
 		if(sl.qty > 0) {
 			// incoming - rate is given
-			var rate = sl.incoming_rate;	
+			var rate = sl.incoming_rate;
 			var add_qty = sl.qty;
 			if(wh.balance_qty < 0) {
 				// negative valuation
@@ -34,11 +34,14 @@
 			if(add_qty)
 				wh.fifo_stack.push([add_qty, sl.incoming_rate, sl.posting_date]);				
 		} else {
+			// called everytime for maintaining fifo stack
+			var fifo_value_diff = this.get_fifo_value_diff(wh, sl);
+
 			// outgoing
 			if(sl.serial_no) {
 				var value_diff = -1 * this.get_serialized_value_diff(sl);
 			} else if(is_fifo) {
-				var value_diff = this.get_fifo_value_diff(wh, sl);
+				var value_diff = fifo_value_diff;
 			} else {
 				// average rate for weighted average
 				var rate = (wh.balance_qty.toFixed(2) == 0.00 ? 0 : 
@@ -84,11 +87,6 @@
 				qty = qty - batch[0];
 			}
 		}
-		if(qty) {
-			// msgprint("Negative values not allowed for FIFO valuation!\
-			// Item " + sl.item_code.bold() + " on " + dateutil.str_to_user(sl.posting_datetime).bold() +
-			// " becomes negative. Values computed will not be accurate.");
-		}
 	
 		// reset the updated stack
 		wh.fifo_stack = fifo_stack.reverse();
@@ -112,9 +110,11 @@
 	get_serialized_buying_rates: function() {
 		var serialized_buying_rates = {};
 		
-		$.each(wn.report_dump.data["Serial No"], function(i, sn) {
-			serialized_buying_rates[sn.name.toLowerCase()] = flt(sn.incoming_rate);
-		});
+		if (wn.report_dump.data["Serial No"]) {
+			$.each(wn.report_dump.data["Serial No"], function(i, sn) {
+				serialized_buying_rates[sn.name.toLowerCase()] = flt(sn.incoming_rate);
+			});
+		}
 		
 		return serialized_buying_rates;
 	},
diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py
index c423363..7e4a73a 100644
--- a/selling/doctype/customer/customer.py
+++ b/selling/doctype/customer/customer.py
@@ -4,7 +4,6 @@
 from __future__ import unicode_literals
 import webnotes
 
-from webnotes.utils import cstr
 from webnotes.model.doc import Document, make_autoname
 from webnotes import msgprint, _
 import webnotes.defaults
@@ -144,20 +143,21 @@
 		if self.doc.lead_name:
 			webnotes.conn.sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
 			
-	def on_rename(self, new, old, merge=False):
+	def after_rename(self, old, new, merge=False):
 		#update customer_name if not naming series
 		if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
-			webnotes.conn.sql("""update `tabCustomer` set customer_name = %s where name = %s""", 
-				(new, old))
+			webnotes.conn.set(self.doc, "customer_name", new)
 		
 		for account in webnotes.conn.sql("""select name, account_name from 
 			tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1):
 			if account.account_name != new:
-				webnotes.rename_doc("Account", account.name, new, merge=merge)
+				merge_account = True if merge and webnotes.conn.get_value("Account", 
+					{"master_name": new, "master_type": "Customer"}) else False
+				webnotes.rename_doc("Account", account.name, new, merge=merge_account)
 
-		#update master_name in doctype account
+		#update master_name in account record
 		webnotes.conn.sql("""update `tabAccount` set master_name = %s, 
-			master_type = 'Customer' where master_name = %s""", (new,old))
+			master_type = 'Customer' where master_name = %s""", (new, old))
 
 @webnotes.whitelist()
 def get_dashboard_info(customer):
diff --git a/selling/doctype/lead/lead.txt b/selling/doctype/lead/lead.txt
index f573a01..01a3aca 100644
--- a/selling/doctype/lead/lead.txt
+++ b/selling/doctype/lead/lead.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-04-10 11:45:37", 
   "docstatus": 0, 
-  "modified": "2013-11-18 15:12:07", 
+  "modified": "2013-11-25 11:37:00", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -392,7 +392,8 @@
   "fieldtype": "Table", 
   "hidden": 1, 
   "label": "Communications", 
-  "options": "Communication"
+  "options": "Communication", 
+  "print_hide": 1
  }, 
  {
   "cancel": 1, 
diff --git a/selling/doctype/opportunity/opportunity.txt b/selling/doctype/opportunity/opportunity.txt
index 604599c..fec94c8 100644
--- a/selling/doctype/opportunity/opportunity.txt
+++ b/selling/doctype/opportunity/opportunity.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-03-07 18:50:30", 
   "docstatus": 0, 
-  "modified": "2013-11-03 14:20:14", 
+  "modified": "2013-11-25 11:36:40", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -429,7 +429,8 @@
   "fieldtype": "Table", 
   "hidden": 1, 
   "label": "Communications", 
-  "options": "Communication"
+  "options": "Communication", 
+  "print_hide": 1
  }, 
  {
   "doctype": "DocPerm", 
diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt
index 0c42722..3862b93 100644
--- a/selling/doctype/quotation/quotation.txt
+++ b/selling/doctype/quotation/quotation.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-24 19:29:08", 
   "docstatus": 0, 
-  "modified": "2013-11-03 14:20:15", 
+  "modified": "2013-11-25 11:35:58", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -836,7 +836,8 @@
   "fieldtype": "Table", 
   "hidden": 1, 
   "label": "Communications", 
-  "options": "Communication"
+  "options": "Communication", 
+  "print_hide": 1
  }, 
  {
   "amend": 1, 
diff --git a/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
index 5e959ff..ca18936 100644
--- a/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
+++ b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
@@ -76,7 +76,7 @@
 	for d in webnotes.conn.sql("""select bd.name, bdd.month, bdd.percentage_allocation 
 		from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd 
 		where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
-			target_details.setdefault(d.name, {}).setdefault(d.month, d.percentage_allocation)
+			target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
 
 	return target_details
 
@@ -115,8 +115,8 @@
 				}))
 
 			tav_dict = sim_map[sd.name][sd.item_group][month]
-			month_percentage = sd.distribution_id and \
-				tdd.get(sd.distribution_id, {}).get(month, 0) or 100.0/12
+			month_percentage = tdd.get(sd.distribution_id, {}).get(month, 0) \
+				if sd.distribution_id else 100.0/12
 			
 			for ad in achieved_details.get(sd.name, {}).get(sd.item_group, []):
 				if (filters["target_on"] == "Quantity"):
diff --git a/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
index 8b41430..08240a7 100644
--- a/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
+++ b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
@@ -73,7 +73,7 @@
 	for d in webnotes.conn.sql("""select bd.name, bdd.month, bdd.percentage_allocation 
 		from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
 		where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
-			target_details.setdefault(d.name, {}).setdefault(d.month, d.percentage_allocation)
+			target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
 
 	return target_details
 
@@ -113,8 +113,8 @@
 				}))
 
 			tav_dict = tim_map[td.name][td.item_group][month]
-			month_percentage = td.distribution_id and \
-				tdd.get(td.distribution_id, {}).get(month, 0) or 100.0/12
+			month_percentage = tdd.get(td.distribution_id, {}).get(month, 0) \
+				if td.distribution_id else 100.0/12
 
 			for ad in achieved_details.get(td.name, {}).get(td.item_group, []):
 				if (filters["target_on"] == "Quantity"):
diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py
index f31fddb..12281b4 100644
--- a/setup/doctype/company/company.py
+++ b/setup/doctype/company/company.py
@@ -80,7 +80,7 @@
 				# update in home page in settings
 				website_settings = webnotes.bean("Website Settings", "Website Settings")
 				website_settings.doc.home_page = webpage.doc.name
-				website_settings.doc.banner_html = """<h3 style='margin-bottom: 20px;'>""" + self.doc.name + "</h3>"
+				website_settings.doc.brand_html = self.doc.name
 				website_settings.doc.copyright = self.doc.name
 				website_settings.doclist.append({
 					"doctype": "Top Bar Item",
@@ -302,18 +302,17 @@
 			where doctype='Global Defaults' and field='default_company' 
 			and value=%s""", self.doc.name)
 			
-	def on_rename(self,newdn,olddn, merge=False):
+	def before_rename(self, olddn, newdn, merge=False):
 		if merge:
-			msgprint(_("Sorry. Companies cannot be merged"), raise_exception=True)
-		
-		webnotes.conn.sql("""update `tabCompany` set company_name=%s
-			where name=%s""", (newdn, olddn))
-		
-		webnotes.conn.sql("""update `tabSingles` set value=%s
-			where doctype='Global Defaults' and field='default_company' 
-			and value=%s""", (newdn, olddn))
-		
-		webnotes.defaults.clear_default("company", value=olddn)
+			webnotes.throw(_("Sorry, companies cannot be merged"))
+	
+	def after_rename(self, olddn, newdn, merge=False):
+		webnotes.conn.set(self.doc, "company_name", newdn)
+
+		webnotes.conn.sql("""update `tabDefaultValue` set defvalue=%s 
+			where defkey='Company' and defvalue=%s""", (newdn, olddn))
+
+		webnotes.defaults.clear_cache()
 
 @webnotes.whitelist()
 def replace_abbr(company, old, new):
@@ -329,3 +328,12 @@
 	for dt in ["Account", "Cost Center", "Warehouse"]:
 		_rename_record(dt)
 		webnotes.conn.commit()
+
+def get_name_with_abbr(name, company):
+	company_abbr = webnotes.conn.get_value("Company", company, "abbr")		
+	parts = name.split(" - ")
+
+	if parts[-1].lower() != company_abbr.lower():
+		parts.append(company_abbr)
+			
+	return " - ".join(parts)
diff --git a/setup/doctype/email_settings/email_settings.txt b/setup/doctype/email_settings/email_settings.txt
index 292b853..9e8c442 100644
--- a/setup/doctype/email_settings/email_settings.txt
+++ b/setup/doctype/email_settings/email_settings.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-03-25 17:53:21", 
   "docstatus": 0, 
-  "modified": "2013-07-09 10:41:38", 
+  "modified": "2013-11-22 12:30:07", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -86,7 +86,7 @@
   "doctype": "DocField", 
   "fieldname": "always_use_login_id_as_sender", 
   "fieldtype": "Check", 
-  "label": "Always use Login Id as sender"
+  "label": "Always use above Login Id as sender"
  }, 
  {
   "doctype": "DocField", 
diff --git a/setup/doctype/item_group/templates/generators/item_group.html b/setup/doctype/item_group/templates/generators/item_group.html
index ba32d5c..e80d0a2 100644
--- a/setup/doctype/item_group/templates/generators/item_group.html
+++ b/setup/doctype/item_group/templates/generators/item_group.html
@@ -3,7 +3,7 @@
 {% block content %}
 {% include 'app/stock/doctype/item/templates/includes/product_search_box.html' %}
 {% include 'app/stock/doctype/item/templates/includes/product_breadcrumbs.html' %}
-<div class="col-md-12">
+<div class="container content">
 	{% if slideshow %}<!-- slideshow -->
 	{% include "lib/website/doctype/website_slideshow/templates/includes/slideshow.html" %}
 	{% endif %}
@@ -13,7 +13,7 @@
 	<h3>{{ name }}</h3>
 	{% endif %}
 </div>
-<div class="col-md-12">
+<div class="container content">
 	{% if sub_groups %}
 	<hr />
 	<div class="row">
diff --git a/setup/doctype/sales_partner/templates/generators/partner.html b/setup/doctype/sales_partner/templates/generators/partner.html
index eb1481b..f0e43f0 100644
--- a/setup/doctype/sales_partner/templates/generators/partner.html
+++ b/setup/doctype/sales_partner/templates/generators/partner.html
@@ -1,7 +1,7 @@
 {% extends base_template %}
 
 {% block content %}
-	<div class="col-md-12" itemscope itemtype="http://schema.org/Organization">
+	<div class="container content" itemscope itemtype="http://schema.org/Organization">
 		<div class="row">
 			<div class="col-md-4">
 				{% if logo -%}
diff --git a/setup/doctype/sales_partner/templates/pages/partners.html b/setup/doctype/sales_partner/templates/pages/partners.html
index 14c72ae..eabceb2 100644
--- a/setup/doctype/sales_partner/templates/pages/partners.html
+++ b/setup/doctype/sales_partner/templates/pages/partners.html
@@ -3,7 +3,7 @@
 {% set title="Partners" %}
 
 {% block content %}
-	<div class="col-md-12">
+	<div class="container content">
 		<h2 id="blog-title">{{ title }}</h2>
 		<hr>
 		{% for partner_info in partners %}
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index a7a78a2..121226a 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -253,14 +253,44 @@
 		webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
 		WebsiteGenerator.on_trash(self)
 
-	def on_rename(self, newdn, olddn, merge=False):
-		webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
+	def before_rename(self, olddn, newdn, merge=False):
+		if merge:
+			# Validate properties before merging
+			field_list = ["stock_uom", "is_stock_item", "has_serial_no", "has_batch_no"]
+			new_properties = [cstr(d) for d in webnotes.conn.get_value("Item", newdn, field_list)]
+			if new_properties != [cstr(self.doc.fields[fld]) for fld in field_list]:
+				webnotes.throw(_("To merge, following properties must be same for both items")
+					+ ": \n" + ", ".join([self.meta.get_label(fld) for fld in field_list]))
+
+			webnotes.conn.sql("delete from `tabBin` where item_code=%s", olddn)
+
+	def after_rename(self, olddn, newdn, merge):
+		webnotes.conn.set_value("Item", newdn, "item_code", newdn)
+		self.update_website_page_name()
+			
+		if merge:
+			self.set_last_purchase_rate(newdn)
+			self.recalculate_bin_qty(newdn)
+			
+	def update_website_page_name(self):
 		if self.doc.page_name:
+			self.update_website()
 			from webnotes.webutils import clear_cache
 			clear_cache(self.doc.page_name)
 			
-		if merge:
-			from stock.stock_ledger import update_entries_after
-			for wh in webnotes.conn.sql("""select warehouse from `tabBin` 
-				where item_code=%s""", newdn):
-					update_entries_after({"item_code": newdn, "warehouse": wh[0]})
+	def set_last_purchase_rate(self, newdn):
+		from buying.utils import get_last_purchase_details
+		last_purchase_rate = get_last_purchase_details(newdn).get("purchase_rate", 0)
+		webnotes.conn.set_value("Item", newdn, "last_purchase_rate", last_purchase_rate)
+			
+	def recalculate_bin_qty(self, newdn):
+		from utilities.repost_stock import repost_stock
+		webnotes.conn.auto_commit_on_many_writes = 1
+		webnotes.conn.set_default("allow_negative_stock", 1)
+		
+		for warehouse in webnotes.conn.sql("select name from `tabWarehouse`"):
+			repost_stock(newdn, warehouse[0])
+		
+		webnotes.conn.set_default("allow_negative_stock", 
+			webnotes.conn.get_value("Stock Settings", None, "allow_negative_stock"))
+		webnotes.conn.auto_commit_on_many_writes = 0
diff --git a/stock/doctype/item/templates/generators/item.html b/stock/doctype/item/templates/generators/item.html
index a89eada..545693d 100644
--- a/stock/doctype/item/templates/generators/item.html
+++ b/stock/doctype/item/templates/generators/item.html
@@ -24,7 +24,7 @@
 {% block content %}
 	{% include 'app/stock/doctype/item/templates/includes/product_search_box.html' %}
 	{% include 'app/stock/doctype/item/templates/includes/product_breadcrumbs.html' %}
-	<div class="col-md-12 product-page-content" itemscope itemtype="http://schema.org/Product">
+	<div class="container content product-page-content" itemscope itemtype="http://schema.org/Product">
 		<div class="row">
 			<div class="col-md-6">
 				{% if slideshow %}
diff --git a/stock/doctype/item/templates/includes/product_breadcrumbs.html b/stock/doctype/item/templates/includes/product_breadcrumbs.html
index f073e6f..e880364 100644
--- a/stock/doctype/item/templates/includes/product_breadcrumbs.html
+++ b/stock/doctype/item/templates/includes/product_breadcrumbs.html
@@ -1,12 +1,10 @@
 {% if obj.parent_groups and (obj.parent_groups|length) > 1 %}
-<div class="col-md-12">
-	<div class="clearfix">
-		<ul class="breadcrumb">
-			{% for ig in obj.parent_groups[:-1] %}
-			<li><a href="{{ ig.page_name }}.html">{{ ig.name }}</a></li>
-			{% endfor %}
-			<li class="active">{{ obj.parent_groups[-1].name }}</li>
-		</ul>
-	</div>
+<div class="container">
+	<ul class="breadcrumb">
+		{% for ig in obj.parent_groups[:-1] %}
+		<li><a href="{{ ig.page_name }}.html">{{ ig.name }}</a></li>
+		{% endfor %}
+		<li class="active">{{ obj.parent_groups[-1].name }}</li>
+	</ul>
 </div>
 {% endif %}
\ No newline at end of file
diff --git a/stock/doctype/item/templates/includes/product_in_list.html b/stock/doctype/item/templates/includes/product_in_list.html
index b3e5b86..c501283 100644
--- a/stock/doctype/item/templates/includes/product_in_list.html
+++ b/stock/doctype/item/templates/includes/product_in_list.html
@@ -1,5 +1,5 @@
 <!-- TODO product listing -->
-<div class="col-md-12">
+<div class="container content">
 	<div style="height: 120px; overflow: hidden;">
 		<a href="{{ page_name }}">
 		{%- if website_image -%}
diff --git a/stock/doctype/item/templates/includes/product_search_box.html b/stock/doctype/item/templates/includes/product_search_box.html
index 00c001b..0f44eea 100644
--- a/stock/doctype/item/templates/includes/product_search_box.html
+++ b/stock/doctype/item/templates/includes/product_search_box.html
@@ -1,15 +1,13 @@
-<div class="row clearfix">
-	<div class="pull-right" style="margin-top: 15px; margin-bottom: 15px;">
-		<form class="form-search">
-			<div class="input-group col-md-4 col-md-offset-8">
-				<input class="form-control" type="text" id="product-search" placeholder="Product Search...">
-				<span class="input-group-btn">
-					<button class="btn btn-default" type="button" id="btn-product-search">
-						<i class="icon-search"></i></button>
-				</span>
-			</div>
-		</form>
-	</div>
+<div class="container" style="margin-bottom: 7px;">
+	<form class="form-inline form-search row">
+		<div class="input-group col-md-4 col-md-offset-8">
+			<input class="form-control" type="text" id="product-search" placeholder="Product Search...">
+			<span class="input-group-btn">
+				<button class="btn btn-default" type="button" id="btn-product-search">
+					<i class="icon-search"></i></button>
+			</span>
+		</div>
+	</form>
 	<script>
 		// redirect to product search page
 		$(document).ready(function() {
diff --git a/stock/doctype/item/templates/pages/product_search.html b/stock/doctype/item/templates/pages/product_search.html
index 9c6eeab..132e3b1 100644
--- a/stock/doctype/item/templates/pages/product_search.html
+++ b/stock/doctype/item/templates/pages/product_search.html
@@ -18,7 +18,7 @@
 </script>
 
 {% include "app/stock/doctype/item/templates/includes/product_search_box.html" %}
-<div class="col-md-12">
+<div class="container content">
 	<h3 class="search-results">Search Results</h3>
 	<div id="search-list" class="row">
 		
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js
index 365444a..c647305 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -20,7 +20,7 @@
 				cur_frm.add_custom_button(wn._('Make Purchase Invoice'), 
 					this.make_purchase_invoice);
 			}
-			cur_frm.add_custom_button(wn._('Send SMS'), cur_frm.cscript['Send SMS'], "icon-mobile-phone");
+			cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
 			
 			this.show_stock_ledger();
 			this.show_general_ledger();
diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py
index c0f8b4e..c7a10ed 100644
--- a/stock/doctype/serial_no/serial_no.py
+++ b/stock/doctype/serial_no/serial_no.py
@@ -6,7 +6,7 @@
 
 from webnotes.utils import cint, getdate, cstr, flt, add_days
 import datetime
-from webnotes import msgprint, _, ValidationError
+from webnotes import _, ValidationError
 
 from controllers.stock_controller import StockController
 
@@ -157,11 +157,12 @@
 			webnotes.throw(_("Cannot delete Serial No in warehouse. \
 				First remove from warehouse, then delete.") + ": " + self.doc.name)
 	
-	def on_rename(self, new, old, merge=False):
-		"""rename serial_no text fields"""
+	def before_rename(self, old, new, merge=False):
 		if merge:
-			msgprint(_("Sorry. Serial Nos. cannot be merged"), raise_exception=True)
-		
+			webnotes.throw(_("Sorry, Serial Nos cannot be merged"))
+			
+	def after_rename(self, old, new, merge=False):
+		"""rename serial_no text fields"""
 		for dt in webnotes.conn.sql("""select parent from tabDocField 
 			where fieldname='serial_no' and fieldtype='Text'"""):
 			
diff --git a/stock/doctype/warehouse/warehouse.js b/stock/doctype/warehouse/warehouse.js
index 62d9ae7..ac6ac63 100644
--- a/stock/doctype/warehouse/warehouse.js
+++ b/stock/doctype/warehouse/warehouse.js
@@ -5,18 +5,6 @@
 	cur_frm.toggle_display('warehouse_name', doc.__islocal);
 }
 
-cur_frm.cscript.merge = function(doc, cdt, cdn) {
-	if (!doc.merge_with) {
-		msgprint(wn._("Please enter the warehouse to which you want to merge?"));
-		return;
-	}
-	var check = confirm(wn._("Are you sure you want to merge this warehouse into " 
-		+ doc.merge_with + "?"));
-	if (check) {
-		return $c_obj(make_doclist(cdt, cdn), 'merge_warehouses', '', '');
-	}
-}
-
 cur_frm.set_query("create_account_under", function() {
 	return {
 		filters: {
diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py
index 567cf28..4869d39 100644
--- a/stock/doctype/warehouse/warehouse.py
+++ b/stock/doctype/warehouse/warehouse.py
@@ -55,47 +55,6 @@
 			else:
 				webnotes.throw(_("Please enter account group under which account \
 					for warehouse ") + self.doc.name +_(" will be created"))
-			
-	def on_rename(self, new, old, merge=False):
-		webnotes.conn.set_value("Account", {"account_type": "Warehouse", "master_name": old}, 
-			"master_name", new)
-			
-		if merge:
-			from stock.stock_ledger import update_entries_after
-			for item_code in webnotes.conn.sql("""select item_code from `tabBin` 
-				where warehouse=%s""", new):
-					update_entries_after({"item_code": item_code, "warehouse": new})
-
-	def merge_warehouses(self):
-		webnotes.conn.auto_commit_on_many_writes = 1
-		
-		# get items which dealt with current warehouse
-		items = webnotes.conn.sql("select item_code from tabBin where warehouse=%s"	, self.doc.name)
-		# delete old bins
-		webnotes.conn.sql("delete from tabBin where warehouse=%s", self.doc.name)
-		
-		# replace link fields
-		from webnotes.model import rename_doc
-		link_fields = rename_doc.get_link_fields('Warehouse')
-		rename_doc.update_link_field_values(link_fields, self.doc.name, self.doc.merge_with)
-		
-		account_link_fields = rename_doc.get_link_fields('Account')
-		old_warehouse_account = webnotes.conn.get_value("Account", {"master_name": self.doc.name})
-		new_warehouse_account = webnotes.conn.get_value("Account", 
-			{"master_name": self.doc.merge_with})
-		rename_doc.update_link_field_values(account_link_fields, old_warehouse_account, 
-			new_warehouse_account)
-			
-		webnotes.conn.delete_doc("Account", old_warehouse_account)
-		
-		from utilities.repost_stock import repost
-		for item_code in items:
-			repost(item_code[0], self.doc.merge_with)
-			
-		webnotes.conn.auto_commit_on_many_writes = 0
-		
-		msgprint("Warehouse %s merged into %s. Now you can delete warehouse: %s" 
-			% (self.doc.name, self.doc.merge_with, self.doc.name))
 		
 	def on_trash(self):
 		# delete bin
@@ -110,15 +69,61 @@
 				webnotes.conn.sql("delete from `tabBin` where name = %s", d['name'])
 				
 		warehouse_account = webnotes.conn.get_value("Account", 
-			{"account_type": "Warehosue", "master_name": self.doc.name})
+			{"account_type": "Warehouse", "master_name": self.doc.name})
 		if warehouse_account:
 			webnotes.delete_doc("Account", warehouse_account)
 				
-		# delete cancelled sle
-		if webnotes.conn.sql("""select name from `tabStock Ledger Entry` where warehouse = %s""", 
-				self.doc.name):
-			msgprint("""Warehosue can not be deleted as stock ledger entry 
+		if sql("""select name from `tabStock Ledger Entry` where warehouse = %s""", self.doc.name):
+			msgprint("""Warehouse can not be deleted as stock ledger entry 
 				exists for this warehouse.""", raise_exception=1)
-		else:
-			webnotes.conn.sql("delete from `tabStock Ledger Entry` where warehouse = %s", 
-				self.doc.name)
+			
+	def before_rename(self, olddn, newdn, merge=False):
+		# Add company abbr if not provided
+		from setup.doctype.company.company import get_name_with_abbr
+		new_warehouse = get_name_with_abbr(newdn, self.doc.company)
+
+		if merge:
+			if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"):
+				webnotes.throw(_("Both Warehouse must belong to same Company"))
+				
+			webnotes.conn.sql("delete from `tabBin` where warehouse=%s", olddn)
+			
+		self.rename_account(olddn, new_warehouse, merge)
+
+		return new_warehouse
+
+	def after_rename(self, olddn, newdn, merge=False):
+		if merge:
+			self.recalculate_bin_qty(newdn)
+			
+	def recalculate_bin_qty(self, newdn):
+		from utilities.repost_stock import repost_stock
+		webnotes.conn.auto_commit_on_many_writes = 1
+		webnotes.conn.set_default("allow_negative_stock", 1)
+		
+		for item in webnotes.conn.sql("""select distinct item_code from (
+			select name as item_code from `tabItem` where ifnull(is_stock_item, 'Yes')='Yes'
+			union 
+			select distinct item_code from tabBin) a"""):
+				repost_stock(item[0], newdn)
+			
+		webnotes.conn.set_default("allow_negative_stock", 
+			webnotes.conn.get_value("Stock Settings", None, "allow_negative_stock"))
+		webnotes.conn.auto_commit_on_many_writes = 0
+			
+	def rename_account(self, olddn, newdn, merge):
+		old_account = webnotes.conn.get_value("Account", 
+			{"account_type": "Warehouse", "master_name": olddn})
+		if old_account:
+			new_account = None
+			if not merge:
+				if old_account == olddn:
+					new_account = webnotes.rename_doc("Account", olddn, newdn)
+			else:
+				existing_new_account = webnotes.conn.get_value("Account", 
+					{"account_type": "Warehouse", "master_name": newdn})
+				new_account = webnotes.rename_doc("Account", old_account, 
+					existing_new_account or newdn, merge=True if existing_new_account else False)
+
+			if new_account:
+				webnotes.conn.set_value("Account", new_account, "master_name", newdn)
\ No newline at end of file
diff --git a/stock/doctype/warehouse/warehouse.txt b/stock/doctype/warehouse/warehouse.txt
index 39e335f..e194349 100644
--- a/stock/doctype/warehouse/warehouse.txt
+++ b/stock/doctype/warehouse/warehouse.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-03-07 18:50:32", 
   "docstatus": 0, 
-  "modified": "2013-10-28 16:42:07", 
+  "modified": "2013-11-19 12:12:33", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -20,7 +20,8 @@
   "name": "__common__", 
   "parent": "Warehouse", 
   "parentfield": "fields", 
-  "parenttype": "DocType"
+  "parenttype": "DocType", 
+  "permlevel": 0
  }, 
  {
   "doctype": "DocPerm", 
@@ -42,7 +43,6 @@
   "fieldtype": "Section Break", 
   "label": "Warehouse Detail", 
   "oldfieldtype": "Section Break", 
-  "permlevel": 0, 
   "read_only": 0
  }, 
  {
@@ -52,7 +52,6 @@
   "label": "Warehouse Name", 
   "oldfieldname": "warehouse_name", 
   "oldfieldtype": "Data", 
-  "permlevel": 0, 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -65,7 +64,6 @@
   "oldfieldname": "company", 
   "oldfieldtype": "Link", 
   "options": "Company", 
-  "permlevel": 0, 
   "read_only": 0, 
   "reqd": 1, 
   "search_index": 1
@@ -95,7 +93,6 @@
   "fieldtype": "Table", 
   "label": "Warehouse Users", 
   "options": "Warehouse User", 
-  "permlevel": 0, 
   "read_only": 0
  }, 
  {
@@ -104,7 +101,6 @@
   "fieldname": "warehouse_contact_info", 
   "fieldtype": "Section Break", 
   "label": "Warehouse Contact Info", 
-  "permlevel": 0, 
   "read_only": 0
  }, 
  {
@@ -115,7 +111,6 @@
   "label": "Email Id", 
   "oldfieldname": "email_id", 
   "oldfieldtype": "Data", 
-  "permlevel": 0, 
   "print_hide": 0, 
   "read_only": 0
  }, 
@@ -127,7 +122,6 @@
   "oldfieldname": "phone_no", 
   "oldfieldtype": "Int", 
   "options": "Phone", 
-  "permlevel": 0, 
   "read_only": 0
  }, 
  {
@@ -138,7 +132,6 @@
   "oldfieldname": "mobile_no", 
   "oldfieldtype": "Int", 
   "options": "Phone", 
-  "permlevel": 0, 
   "read_only": 0
  }, 
  {
@@ -146,7 +139,6 @@
   "fieldname": "column_break0", 
   "fieldtype": "Column Break", 
   "oldfieldtype": "Column Break", 
-  "permlevel": 0, 
   "read_only": 0
  }, 
  {
@@ -156,7 +148,6 @@
   "label": "Address Line 1", 
   "oldfieldname": "address_line_1", 
   "oldfieldtype": "Data", 
-  "permlevel": 0, 
   "read_only": 0
  }, 
  {
@@ -166,7 +157,6 @@
   "label": "Address Line 2", 
   "oldfieldname": "address_line_2", 
   "oldfieldtype": "Data", 
-  "permlevel": 0, 
   "read_only": 0
  }, 
  {
@@ -177,7 +167,6 @@
   "label": "City", 
   "oldfieldname": "city", 
   "oldfieldtype": "Data", 
-  "permlevel": 0, 
   "read_only": 0, 
   "reqd": 0
  }, 
@@ -189,7 +178,6 @@
   "oldfieldname": "state", 
   "oldfieldtype": "Select", 
   "options": "Suggest", 
-  "permlevel": 0, 
   "read_only": 0
  }, 
  {
@@ -199,33 +187,6 @@
   "label": "PIN", 
   "oldfieldname": "pin", 
   "oldfieldtype": "Int", 
-  "permlevel": 0, 
-  "read_only": 0
- }, 
- {
-  "description": "This feature is for merging duplicate warehouses. It will replace all the links of this warehouse by \"Merge Into\" warehouse. After merging you can delete this warehouse, as stock level for this warehouse will be zero.", 
-  "doctype": "DocField", 
-  "fieldname": "merge_warehouses_section", 
-  "fieldtype": "Section Break", 
-  "label": "Merge Warehouses", 
-  "permlevel": 2, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "merge_with", 
-  "fieldtype": "Link", 
-  "label": "Merge Into", 
-  "options": "Warehouse", 
-  "permlevel": 2, 
-  "read_only": 0
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "merge", 
-  "fieldtype": "Button", 
-  "label": "Merge", 
-  "permlevel": 2, 
   "read_only": 0
  }, 
  {
diff --git a/stock/page/stock_ageing/stock_ageing.js b/stock/page/stock_ageing/stock_ageing.js
index 7728e3c..6c626e2 100644
--- a/stock/page/stock_ageing/stock_ageing.js
+++ b/stock/page/stock_ageing/stock_ageing.js
@@ -25,7 +25,7 @@
 			page: wrapper,
 			parent: $(wrapper).find('.layout-main'),
 			appframe: wrapper.appframe,
-			doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group", "Brand"],
+			doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group", "Brand", "Serial No"],
 		})
 	},
 	setup_columns: function() {
@@ -175,7 +175,7 @@
 			grid: { hoverable: true, clickable: true },
 			xaxis: {  
 				ticks: $.map(me.data, function(item, idx) { return [[idx+1, item.name]] }),
-				max: 20
+				max: 15
 			},
 			series: { downsample: { threshold: 1000 } }
 		}
diff --git a/stock/page/stock_ledger/stock_ledger.js b/stock/page/stock_ledger/stock_ledger.js
index 8ffe0ff..08a455e 100644
--- a/stock/page/stock_ledger/stock_ledger.js
+++ b/stock/page/stock_ledger/stock_ledger.js
@@ -21,7 +21,7 @@
 			page: wrapper,
 			parent: $(wrapper).find('.layout-main'),
 			appframe: wrapper.appframe,
-			doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand"],
+			doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", "Serial No"],
 		})
 	},
 
diff --git a/stock/page/stock_level/stock_level.js b/stock/page/stock_level/stock_level.js
index 088a256..c508791 100644
--- a/stock/page/stock_level/stock_level.js
+++ b/stock/page/stock_level/stock_level.js
@@ -27,7 +27,7 @@
 			parent: $(wrapper).find('.layout-main'),
 			appframe: wrapper.appframe,
 			doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Production Order", 
-				"Material Request Item", "Purchase Order Item", "Sales Order Item", "Brand"],
+				"Material Request Item", "Purchase Order Item", "Sales Order Item", "Brand", "Serial No"],
 		});
 		
 		this.wrapper.bind("make", function() {
diff --git a/support/doctype/support_ticket/templates/pages/ticket.html b/support/doctype/support_ticket/templates/pages/ticket.html
index 4b41dc2..1732e77 100644
--- a/support/doctype/support_ticket/templates/pages/ticket.html
+++ b/support/doctype/support_ticket/templates/pages/ticket.html
@@ -9,7 +9,7 @@
 } %}
 
 {% block content %}
-<div class="col-md-12">
+<div class="container content">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a></li>
     	<li><a href="tickets">My Tickets</a></li>
diff --git a/utilities/doctype/address/templates/pages/address.html b/utilities/doctype/address/templates/pages/address.html
index f02d687..5eaefd5 100644
--- a/utilities/doctype/address/templates/pages/address.html
+++ b/utilities/doctype/address/templates/pages/address.html
@@ -37,7 +37,7 @@
 {%- endmacro %}
 
 {% block content %}
-<div class="col-md-12">
+<div class="container content">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a></li>
     	<li><a href="addresses">My Addresses</a></li>
diff --git a/utilities/doctype/address/templates/pages/addresses.html b/utilities/doctype/address/templates/pages/addresses.html
index d56c734..6fe36a9 100644
--- a/utilities/doctype/address/templates/pages/addresses.html
+++ b/utilities/doctype/address/templates/pages/addresses.html
@@ -3,7 +3,7 @@
 {% set title="My Addresses" %}
 
 {% block content %}
-<div class="col-md-12">
+<div class="container content">
     <ul class="breadcrumb">
     	<li><a href="index">Home</a></li>
     	<li class="active"><i class="icon-map-marker icon-fixed-width"></i> My Addresses</li>
diff --git a/utilities/repost_stock.py b/utilities/repost_stock.py
index bc93e1e..48ff25f 100644
--- a/utilities/repost_stock.py
+++ b/utilities/repost_stock.py
@@ -7,18 +7,24 @@
 from webnotes.utils import flt
 
 
-def repost():
+def repost(allow_negative_stock=False):
 	"""
 	Repost everything!
 	"""
 	webnotes.conn.auto_commit_on_many_writes = 1
 	
+	if allow_negative_stock:
+		webnotes.conn.set_default("allow_negative_stock", 1)
+	
 	for d in webnotes.conn.sql("""select distinct item_code, warehouse from 
 		(select item_code, warehouse from tabBin
 		union
 		select item_code, warehouse from `tabStock Ledger Entry`) a"""):
-			repost_stock(d[0], d[1])
-		
+			repost_stock(d[0], d[1], allow_negative_stock)
+			
+	if allow_negative_stock:
+		webnotes.conn.set_default("allow_negative_stock", 
+			webnotes.conn.get_value("Stock Settings", None, "allow_negative_stock"))
 	webnotes.conn.auto_commit_on_many_writes = 0
 
 def repost_stock(item_code, warehouse):
@@ -38,7 +44,7 @@
 		update_entries_after({ "item_code": item_code, "warehouse": warehouse })
 	except:
 		pass
-
+	
 def get_reserved_qty(item_code, warehouse):
 	reserved_qty = webnotes.conn.sql("""
 		select