Merge branch 'hotfix'
diff --git a/.travis.yml b/.travis.yml
index cb3dd5e..12a73c9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,9 +23,6 @@
   - cd ~/frappe-bench
   - bench get-app erpnext $TRAVIS_BUILD_DIR
   - bench use test_site
-  - bench setup redis-cache
-  - bench setup redis-async-broker
-  - bench setup procfile --with-celery-broker
   - bench reinstall
   - bench build
   - bench build-website
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index 9ebc832..8bad8a4 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
 from __future__ import unicode_literals
-__version__ = '6.27.5'
+__version__ = '6.27.6'
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 74b749a..aaf3318 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -353,25 +353,31 @@
 			self.remark = ("\n").join(r) #User Remarks is not mandatory
 
 	def set_print_format_fields(self):
-		total_amount = 0.0
-		bank_account_currency = None
-		pay_to_recd_from = None
+		bank_amount = party_amount = total_amount = 0.0
+		currency = bank_account_currency = party_account_currency = pay_to_recd_from= None
 		for d in self.get('accounts'):
 			if d.party_type and d.party:
 				if not pay_to_recd_from:
 					pay_to_recd_from = frappe.db.get_value(d.party_type, d.party,
 						"customer_name" if d.party_type=="Customer" else "supplier_name")
 
+				party_amount += (d.debit_in_account_currency or d.credit_in_account_currency)
+				party_account_currency = d.account_currency
+
 			elif frappe.db.get_value("Account", d.account, "account_type") in ["Bank", "Cash"]:
-				total_amount += (d.debit_in_account_currency or d.credit_in_account_currency)
+				bank_amount += (d.debit_in_account_currency or d.credit_in_account_currency)
 				bank_account_currency = d.account_currency
 
 		if pay_to_recd_from:
 			self.pay_to_recd_from = pay_to_recd_from
-		else:
-			total_amount = 0
+			if bank_amount:
+				total_amount = bank_amount
+				currency = bank_account_currency
+			else:
+				total_amount = party_amount
+				currency = party_account_currency
 
-		self.set_total_amount(total_amount, bank_account_currency)
+		self.set_total_amount(total_amount, currency)
 
 	def set_total_amount(self, amt, currency):
 		self.total_amount = amt
@@ -664,7 +670,7 @@
 	bank_row.cost_center = cost_center
 
 	amount = args.get("debit_in_account_currency") or args.get("amount")
-	
+
 	if bank_row.account_currency == args.get("party_account_currency"):
 		bank_row.set(args.get("amount_field_bank"), amount)
 	else:
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 2d45abe..a1144f2 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -375,7 +375,7 @@
 			frappe.throw(_("Cash or Bank Account is mandatory for making payment entry"))
 
 		if flt(self.paid_amount) + flt(self.write_off_amount) \
-				- flt(self.base_grand_total) > 1/(10**(self.precision("base_grand_total") + 1)):
+				- flt(self.grand_total) > 1/(10**(self.precision("grand_total") + 1)):
 			frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total"""))
 
 
@@ -471,7 +471,7 @@
 			frappe.db.set(self,'paid_amount',0)
 
 		frappe.db.set(self, 'base_paid_amount',
-			flt(self.paid_amount*self.conversion_rate, self.precision("base_paid_amount")))		
+			flt(self.paid_amount*self.conversion_rate, self.precision("base_paid_amount")))
 
 	def check_prev_docstatus(self):
 		for d in self.get('items'):
diff --git a/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.json b/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.json
index 41b7dd1..691a5c3 100644
--- a/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.json
+++ b/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.json
@@ -7,12 +7,12 @@
  "doctype": "Report", 
  "idx": 1, 
  "is_standard": "Yes", 
- "modified": "2015-11-02 12:32:02.048551", 
+ "modified": "2016-04-04 17:27:19.104519", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Delivered Items To Be Billed", 
  "owner": "Administrator", 
- "query": "select\n    `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n\t`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n\t`tabDelivery Note`.`posting_date` as \"Date:Date\",\n\t`tabDelivery Note`.`project` as \"Project\",\n\t`tabDelivery Note Item`.`item_code` as \"Item:Link/Item:120\",\n\t(`tabDelivery Note Item`.`qty` - ifnull((select sum(qty) from `tabSales Invoice Item` \n\t    where `tabSales Invoice Item`.docstatus=1 and \n            `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n\t        `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\n\t\tas \"Qty:Float:110\",\n\t(`tabDelivery Note Item`.`base_amount` - ifnull((select sum(base_amount) from `tabSales Invoice Item` \n        where `tabSales Invoice Item`.docstatus=1 and \n            `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n            `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\n\t\tas \"Amount:Currency:110\",\n\t`tabDelivery Note Item`.`item_name` as \"Item Name::150\",\n\t`tabDelivery Note Item`.`description` as \"Description::200\",\n\t`tabDelivery Note`.`company` as \"Company:Link/Company:\"\nfrom `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n    `tabDelivery Note`.docstatus = 1 and\n\t`tabDelivery Note`.`status` not in (\"Stopped\", \"Closed\") and\n    `tabDelivery Note`.name = `tabDelivery Note Item`.parent and\n    (`tabDelivery Note Item`.qty > ifnull((select sum(qty) from `tabSales Invoice Item` \n        where `tabSales Invoice Item`.docstatus=1 and \n            `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n            `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\norder by `tabDelivery Note`.`name` desc", 
+ "query": "select\n    `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n\t`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n\t`tabDelivery Note`.`posting_date` as \"Date:Date\",\n\t`tabDelivery Note`.`project` as \"Project\",\n\t`tabDelivery Note Item`.`item_code` as \"Item:Link/Item:120\",\n\t`tabDelivery Note Item`.`billed_amt` as \"Pending Amount:Currency:110\",\n\t`tabDelivery Note Item`.`item_name` as \"Item Name::150\",\n\t`tabDelivery Note Item`.`description` as \"Description::200\",\n\t`tabDelivery Note`.`company` as \"Company:Link/Company:\"\nfrom `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n    `tabDelivery Note`.docstatus = 1 and\n\t`tabDelivery Note`.`status` not in (\"Stopped\", \"Closed\") and\n    `tabDelivery Note`.name = `tabDelivery Note Item`.parent and\n    `tabDelivery Note`.per_billed < 100\norder by `tabDelivery Note`.`name` desc", 
  "ref_doctype": "Sales Invoice", 
  "report_name": "Delivered Items To Be Billed", 
  "report_type": "Query Report"
diff --git a/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.json b/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.json
index 8f41ac4..47b62a8 100644
--- a/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.json
+++ b/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.json
@@ -7,7 +7,7 @@
  "doctype": "Report", 
  "idx": 1, 
  "is_standard": "Yes", 
- "modified": "2016-02-23 18:48:42.372321", 
+ "modified": "2016-04-01 08:26:43.868609", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Ordered Items To Be Billed", 
diff --git a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json b/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json
index c5314e6..72e9396 100644
--- a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json
+++ b/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json
@@ -7,7 +7,7 @@
  "doctype": "Report", 
  "idx": 1, 
  "is_standard": "Yes", 
- "modified": "2016-02-23 18:51:21.968327", 
+ "modified": "2016-04-01 08:27:32.122070", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Order Items To Be Billed", 
diff --git a/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.json b/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.json
index 0b8597d..c38a7bb 100644
--- a/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.json
+++ b/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.json
@@ -7,12 +7,12 @@
  "doctype": "Report", 
  "idx": 1, 
  "is_standard": "Yes", 
- "modified": "2015-11-02 12:33:11.681513", 
+ "modified": "2016-04-04 17:27:29.449124", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Received Items To Be Billed", 
  "owner": "Administrator", 
- "query": "select\n    `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n    `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Receipt`.`posting_date` as \"Date:Date\",\n\t`tabPurchase Receipt Item`.`project` as \"Project\",\n\t`tabPurchase Receipt Item`.`item_code` as \"Item:Link/Item:120\",\n\t(`tabPurchase Receipt Item`.`qty` - ifnull((select sum(qty) from `tabPurchase Invoice Item` \n\t    where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n            `tabPurchase Invoice Item`.docstatus = 1 and\n\t    `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\n\t    as \"Qty:Float:110\",\n\t(`tabPurchase Receipt Item`.`base_amount` - ifnull((select sum(base_amount) \n             from `tabPurchase Invoice Item` \n             where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n            `tabPurchase Invoice Item`.docstatus = 1 and\n            `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\n\t    as \"Amount:Currency:110\",\n\t`tabPurchase Receipt Item`.`item_name` as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.`description` as \"Description::200\",\n\t`tabPurchase Receipt`.`company` as \"Company:Link/Company:\"\nfrom `tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n    `tabPurchase Receipt`.docstatus = 1 and `tabPurchase Receipt`.status != \"Closed\" and \n    `tabPurchase Receipt`.name = `tabPurchase Receipt Item`.parent and\n    (`tabPurchase Receipt Item`.qty > ifnull((select sum(qty) from `tabPurchase Invoice Item` \n        where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n            `tabPurchase Invoice Item`.docstatus=1 and \n            `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\norder by `tabPurchase Receipt`.`name` desc", 
+ "query": "select\n    `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n    `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Receipt`.`posting_date` as \"Date:Date\",\n\t`tabPurchase Receipt Item`.`project` as \"Project\",\n\t`tabPurchase Receipt Item`.`item_code` as \"Item:Link/Item:120\",\n\t`tabPurchase Receipt Item`.`billed_amt` as \"Pending Amount:Currency:110\",\n\t`tabPurchase Receipt Item`.`item_name` as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.`description` as \"Description::200\",\n\t`tabPurchase Receipt`.`company` as \"Company:Link/Company:\"\nfrom `tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n    `tabPurchase Receipt`.docstatus = 1 and `tabPurchase Receipt`.status != \"Closed\" and \n    `tabPurchase Receipt`.name = `tabPurchase Receipt Item`.parent and\n    `tabPurchase Receipt`.per_billed < 100\norder by `tabPurchase Receipt`.`name` desc", 
  "ref_doctype": "Purchase Invoice", 
  "report_name": "Received Items To Be Billed", 
  "report_type": "Query Report"
diff --git a/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.json b/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.json
index c06d33d..4a8d608 100644
--- a/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.json
+++ b/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.json
@@ -7,7 +7,7 @@
  "doctype": "Report", 
  "idx": 1, 
  "is_standard": "Yes", 
- "modified": "2016-02-22 11:27:39.445257", 
+ "modified": "2016-04-01 08:26:52.361800", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Item-wise Purchase History", 
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index eff5f53..91cd0da 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -184,8 +184,8 @@
 			idx desc,
 			name, item_name
 		limit %(start)s, %(page_len)s """.format(key=searchfield,
-			fcond=get_filters_cond(doctype, filters, conditions),
-			mcond=get_match_cond(doctype)),
+			fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
+			mcond=get_match_cond(doctype).replace('%', '%%')),
 			{
 				"today": nowdate(),
 				"txt": "%%%s%%" % txt,
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index d4a64f2..49e0bd3 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -283,8 +283,8 @@
 				last_tax.tax_amount += diff
 				last_tax.tax_amount_after_discount_amount += diff
 				last_tax.total += diff
-				
-				self._set_in_company_currency(last_tax, 
+
+				self._set_in_company_currency(last_tax,
 					["total", "tax_amount", "tax_amount_after_discount_amount"])
 
 	def calculate_totals(self):
@@ -319,22 +319,22 @@
 		self.doc.round_floats_in(self.doc, ["grand_total", "base_grand_total"])
 
 		if self.doc.meta.get_field("rounded_total"):
-			self.doc.rounded_total = round_based_on_smallest_currency_fraction(self.doc.grand_total, 
+			self.doc.rounded_total = round_based_on_smallest_currency_fraction(self.doc.grand_total,
 				self.doc.currency, self.doc.precision("rounded_total"))
 		if self.doc.meta.get_field("base_rounded_total"):
 			company_currency = get_company_currency(self.doc.company)
-			
+
 			self.doc.base_rounded_total = \
-				round_based_on_smallest_currency_fraction(self.doc.base_grand_total, 
+				round_based_on_smallest_currency_fraction(self.doc.base_grand_total,
 					company_currency, self.doc.precision("base_rounded_total"))
 
 	def _cleanup(self):
 		for tax in self.doc.get("taxes"):
 			tax.item_wise_tax_detail = json.dumps(tax.item_wise_tax_detail, separators=(',', ':'))
-			
+
 	def set_discount_amount(self):
 		if not self.doc.discount_amount and self.doc.additional_discount_percentage:
-			self.doc.discount_amount = flt(flt(self.doc.get(scrub(self.doc.apply_discount_on))) 
+			self.doc.discount_amount = flt(flt(self.doc.get(scrub(self.doc.apply_discount_on)))
 				* self.doc.additional_discount_percentage / 100, self.doc.precision("discount_amount"))
 
 	def apply_discount_amount(self):
@@ -397,13 +397,13 @@
 				for adv in self.doc.get("advances")])
 
 			self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance"))
-			
+
 			if self.doc.party_account_currency == self.doc.currency:
 				invoice_total = self.doc.grand_total
 			else:
-				invoice_total = flt(self.doc.grand_total * self.doc.conversion_rate, 
+				invoice_total = flt(self.doc.grand_total * self.doc.conversion_rate,
 					self.doc.precision("grand_total"))
-			
+
 			if invoice_total > 0 and self.doc.total_advance > invoice_total:
 				frappe.throw(_("Advance amount cannot be greater than {0} {1}")
 					.format(self.doc.party_account_currency, invoice_total))
@@ -417,21 +417,23 @@
 		# total_advance is only for non POS Invoice
 		if self.doc.is_return:
 			return
-		
+
 		self.doc.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount"])
+		self._set_in_company_currency(self.doc, ['write_off_amount'])
+
 		if self.doc.party_account_currency == self.doc.currency:
-			total_amount_to_pay = flt(self.doc.grand_total  - self.doc.total_advance 
+			total_amount_to_pay = flt(self.doc.grand_total  - self.doc.total_advance
 				- flt(self.doc.write_off_amount), self.doc.precision("grand_total"))
 		else:
 			total_amount_to_pay = flt(flt(self.doc.grand_total *
-				self.doc.conversion_rate, self.doc.precision("grand_total")) - self.doc.total_advance 
+				self.doc.conversion_rate, self.doc.precision("grand_total")) - self.doc.total_advance
 					- flt(self.doc.base_write_off_amount), self.doc.precision("grand_total"))
-			
+
 		if self.doc.doctype == "Sales Invoice":
 			self.doc.round_floats_in(self.doc, ["paid_amount"])
 			paid_amount = self.doc.paid_amount \
 				if self.doc.party_account_currency == self.doc.currency else self.doc.base_paid_amount
-			self.doc.outstanding_amount = flt(total_amount_to_pay - flt(paid_amount), 
+			self.doc.outstanding_amount = flt(total_amount_to_pay - flt(paid_amount),
 				self.doc.precision("outstanding_amount"))
 		elif self.doc.doctype == "Purchase Invoice":
-			self.doc.outstanding_amount = flt(total_amount_to_pay, self.doc.precision("outstanding_amount"))
\ No newline at end of file
+			self.doc.outstanding_amount = flt(total_amount_to_pay, self.doc.precision("outstanding_amount"))
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index fd54dd7..b25566a 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -7,7 +7,7 @@
 app_description = """ERP made simple"""
 app_icon = "icon-th"
 app_color = "#e74c3c"
-app_version = "6.27.5"
+app_version = "6.27.6"
 app_email = "info@erpnext.com"
 app_license = "GNU General Public License (v3)"
 source_link = "https://github.com/frappe/erpnext"
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index b79b136..e424695 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -71,7 +71,7 @@
 				pp_so.sales_order_date = cstr(r['transaction_date'])
 				pp_so.customer = cstr(r['customer'])
 				pp_so.grand_total = flt(r['base_grand_total'])
-	
+
 	def get_pending_material_requests(self):
 		""" Pull Material Requests that are pending based on criteria selected"""
 		mr_filter = item_filter = ""
@@ -81,7 +81,7 @@
 			mr_filter += " and mr.transaction_date <= %(to_date)s"
 		if self.warehouse:
 			mr_filter += " and mr_item.warehouse = %(warehouse)s"
-			
+
 		if self.fg_item:
 			item_filter += " and item.name = %(item)s"
 
@@ -102,7 +102,7 @@
 			}, as_dict=1)
 
 		self.add_mr_in_table(pending_mr)
-		
+
 	def add_mr_in_table(self, pending_mr):
 		""" Add Material Requests in the table"""
 		self.clear_table("material_requests")
@@ -119,7 +119,7 @@
 			self.get_so_items()
 		elif self.get_items_from == "Material Request":
 			self.get_mr_items()
-		
+
 	def get_so_items(self):
 		so_list = [d.sales_order for d in self.get('sales_orders') if d.sales_order]
 		if not so_list:
@@ -128,7 +128,7 @@
 
 		item_condition = ""
 		if self.fg_item:
-			item_condition = ' and so_item.item_code = "' + self.fg_item + '"'
+			item_condition = ' and so_item.item_code = "{0}"'.format(frappe.db.escape(self.fg_item))
 
 		items = frappe.db.sql("""select distinct parent, item_code, warehouse,
 			(qty - delivered_qty) as pending_qty
@@ -139,7 +139,7 @@
 			(", ".join(["%s"] * len(so_list)), item_condition), tuple(so_list), as_dict=1)
 
 		if self.fg_item:
-			item_condition = ' and pi.item_code = "' + self.fg_item + '"'
+			item_condition = ' and pi.item_code = "{0}"'.format(frappe.db.escape(self.fg_item))
 
 		packed_items = frappe.db.sql("""select distinct pi.parent, pi.item_code, pi.warehouse as warehouse,
 			(((so_item.qty - so_item.delivered_qty) * pi.qty) / so_item.qty)
@@ -153,7 +153,7 @@
 			(", ".join(["%s"] * len(so_list)), item_condition), tuple(so_list), as_dict=1)
 
 		self.add_items(items + packed_items)
-	
+
 	def get_mr_items(self):
 		mr_list = [d.material_request for d in self.get('material_requests') if d.material_request]
 		if not mr_list:
@@ -173,7 +173,7 @@
 			(", ".join(["%s"] * len(mr_list)), item_condition), tuple(mr_list), as_dict=1)
 
 		self.add_items(items)
-		
+
 
 	def add_items(self, items):
 		self.clear_table("items")
@@ -187,13 +187,13 @@
 			pi.bom_no					= item_details and item_details.bom_no or ''
 			pi.planned_qty				= flt(p['pending_qty'])
 			pi.pending_qty				= flt(p['pending_qty'])
-			
+
 			if self.get_items_from == "Sales Order":
 				pi.sales_order		= p['parent']
 			elif self.get_items_from == "Material Request":
 				pi.material_request		= p['parent']
 				pi.material_request_item = p['name']
-			
+
 	def validate_data(self):
 		self.validate_company()
 		for d in self.get('items'):
@@ -201,7 +201,7 @@
 				frappe.throw(_("Please select BOM for Item in Row {0}".format(d.idx)))
 			else:
 				validate_bom_no(d.item_code, d.bom_no)
-	
+
 			if not flt(d.planned_qty):
 				frappe.throw(_("Please enter Planned Qty for Item {0} at row {1}").format(d.item_code, d.idx))
 
@@ -213,17 +213,17 @@
 		validate_uom_is_integer(self, "stock_uom", "planned_qty")
 
 		items = self.get_production_items()
-		
+
 		pro_list = []
 		frappe.flags.mute_messages = True
-		
+
 		for key in items:
 			production_order = self.create_production_order(items[key])
 			if production_order:
 				pro_list.append(production_order)
-		
+
 		frappe.flags.mute_messages = False
-		
+
 		if pro_list:
 			pro_list = ["""<a href="#Form/Production Order/%s" target="_blank">%s</a>""" % \
 				(p, p) for p in pro_list]
@@ -247,14 +247,14 @@
 				"fg_warehouse"			: d.warehouse,
 				"status"				: "Draft",
 			}
-			
+
 			""" Club similar BOM and item for processing in case of Sales Orders """
 			if self.get_items_from == "Material Request":
 				item_details.update({
 					"qty": d.planned_qty
 				})
 				item_dict[(d.item_code, d.material_request_item, d.warehouse)] = item_details
-			
+
 			else:
 				item_details.update({
 					"qty":flt(item_dict.get((d.item_code, d.sales_order, d.warehouse),{})
@@ -275,7 +275,7 @@
 			pro.wip_warehouse = warehouse.get('wip_warehouse')
 		if not pro.fg_warehouse:
 			pro.fg_warehouse = warehouse.get('fg_warehouse')
-		
+
 		try:
 			pro.insert()
 			return pro.name
@@ -283,7 +283,7 @@
 			pass
 
 	def get_so_wise_planned_qty(self):
-		"""	
+		"""
 			bom_dict {
 				bom_no: ['sales_order', 'qty']
 			}
@@ -295,7 +295,7 @@
 			else:
 				bom_dict.setdefault(d.bom_no, []).append([d.sales_order, flt(d.planned_qty)])
 		return bom_dict
-		
+
 	def download_raw_materials(self):
 		""" Create csv data for required raw material to produce finished goods"""
 		self.validate_data()
diff --git a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json
index 4116568..bd49d0b 100644
--- a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json
+++ b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json
@@ -7,7 +7,7 @@
  "doctype": "Report", 
  "idx": 1, 
  "is_standard": "Yes", 
- "modified": "2016-01-28 14:59:04.611174", 
+ "modified": "2016-04-01 08:26:55.705992", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Item-wise Sales History", 
@@ -16,4 +16,4 @@
  "ref_doctype": "Sales Order", 
  "report_name": "Item-wise Sales History", 
  "report_type": "Query Report"
-}
+}
\ No newline at end of file
diff --git a/erpnext/stock/report/items_to_be_requested/items_to_be_requested.json b/erpnext/stock/report/items_to_be_requested/items_to_be_requested.json
index 340577b..92072a8 100644
--- a/erpnext/stock/report/items_to_be_requested/items_to_be_requested.json
+++ b/erpnext/stock/report/items_to_be_requested/items_to_be_requested.json
@@ -1,17 +1,19 @@
 {
- "apply_user_permissions": 1,
- "creation": "2013-08-20 15:08:10",
- "docstatus": 0,
- "doctype": "Report",
- "idx": 1,
- "is_standard": "Yes",
- "modified": "2014-06-03 07:18:17.128918",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Items To Be Requested",
- "owner": "Administrator",
+ "add_total_row": 0, 
+ "apply_user_permissions": 1, 
+ "creation": "2013-08-20 15:08:10", 
+ "disabled": 0, 
+ "docstatus": 0, 
+ "doctype": "Report", 
+ "idx": 1, 
+ "is_standard": "Yes", 
+ "modified": "2016-04-01 08:27:14.436178", 
+ "modified_by": "Administrator", 
+ "module": "Stock", 
+ "name": "Items To Be Requested", 
+ "owner": "Administrator", 
  "query": "SELECT\n    tabBin.item_code as \"Item:Link/Item:120\",\n    tabBin.warehouse as \"Warehouse:Link/Warehouse:120\",\n    tabBin.actual_qty as \"Actual:Float:90\",\n    tabBin.indented_qty as \"Requested:Float:90\",\n    tabBin.reserved_qty as \"Reserved:Float:90\",\n    tabBin.ordered_qty as \"Ordered:Float:90\",\n    tabBin.projected_qty as \"Projected:Float:90\"\nFROM\n    tabBin, tabItem\nWHERE\n    tabBin.item_code = tabItem.name\n    AND tabItem.is_purchase_item = 1\n    AND tabBin.projected_qty < 0\nORDER BY\n    tabBin.projected_qty ASC", 
- "ref_doctype": "Item",
- "report_name": "Items To Be Requested",
+ "ref_doctype": "Item", 
+ "report_name": "Items To Be Requested", 
  "report_type": "Query Report"
-}
+}
\ No newline at end of file
diff --git a/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.json b/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.json
index 6f857a0..4d56519 100644
--- a/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.json
+++ b/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.json
@@ -7,7 +7,7 @@
  "doctype": "Report", 
  "idx": 1, 
  "is_standard": "Yes", 
- "modified": "2015-11-04 12:00:40.085130", 
+ "modified": "2016-04-01 08:27:03.318987", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Ordered Items To Be Delivered", 
diff --git a/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json b/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json
index d62bf76..fd78f28 100644
--- a/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json
+++ b/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json
@@ -7,7 +7,7 @@
  "doctype": "Report", 
  "idx": 1, 
  "is_standard": "Yes", 
- "modified": "2015-11-04 12:01:22.108641", 
+ "modified": "2016-04-01 08:26:59.904034", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Purchase Order Items To Be Received", 
diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim.js b/erpnext/support/doctype/warranty_claim/warranty_claim.js
index 25d65e3..3928577 100644
--- a/erpnext/support/doctype/warranty_claim/warranty_claim.js
+++ b/erpnext/support/doctype/warranty_claim/warranty_claim.js
@@ -85,13 +85,18 @@
 cur_frm.fields_dict['item_code'].get_query = function(doc, cdt, cdn) {
 	if(doc.serial_no) {
 		return{
-			filters:{ 'serial_no': doc.serial_no}
+			doctype: "Serial No",
+			fields: "item_code",
+			filters:{
+				name: doc.serial_no
+			}
 		}
 	}
 	else{
 		return{
 			filters:[
-				['Item', 'docstatus', '!=', 2]
+				['Item', 'docstatus', '!=', 2],
+				['Item', 'disabled', '=', 0]
 			]
 		}
 	}
diff --git a/setup.py b/setup.py
index 581e065..21398cc 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 from pip.req import parse_requirements
 
-version = "6.27.5"
+version = "6.27.6"
 requirements = parse_requirements("requirements.txt", session="")
 
 setup(