Merge pull request #5210 from jinayG/patch-1

Update README.md
diff --git a/.travis.yml b/.travis.yml
index 12a73c9..eac53fd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,10 +13,10 @@
 install:
   - sudo apt-get purge -y mysql-common
   - wget https://raw.githubusercontent.com/frappe/bench/master/install_scripts/setup_frappe.sh
-  - sudo bash setup_frappe.sh --skip-setup-bench --mysql-root-password travis
+  - sudo bash setup_frappe.sh --skip-setup-bench --mysql-root-password travis --bench-branch develop
   - sudo pip install --upgrade pip
   - rm $TRAVIS_BUILD_DIR/.git/shallow
-  - cd ~/ && bench init frappe-bench --frappe-path https://github.com/frappe/frappe.git --frappe-branch develop
+  - bash $TRAVIS_BUILD_DIR/travis/bench_init.sh
   - cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/
 
 script:
diff --git a/ci/fix-mariadb.sh b/ci/fix-mariadb.sh
deleted file mode 100755
index 886ec5e..0000000
--- a/ci/fix-mariadb.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-
-# stolen from http://cgit.drupalcode.org/octopus/commit/?id=db4f837
-includedir=`mysql_config --variable=pkgincludedir`
-thiscwd=`pwd`
-_THIS_DB_VERSION=`mysql -V 2>&1 | tr -d "\n" | cut -d" " -f6 | awk '{ print $1}' | cut -d"-" -f1 | awk '{ print $1}' | sed "s/[\,']//g"`
-if [ "$_THIS_DB_VERSION" = "5.5.40" ] && [ ! -e "$includedir-$_THIS_DB_VERSION-fixed.log" ] ; then
-  cd $includedir
-  sudo patch -p1 < $thiscwd/ci/my_config.h.patch &> /dev/null
-  sudo touch $includedir-$_THIS_DB_VERSION-fixed.log
-fi
diff --git a/ci/my_config.h.patch b/ci/my_config.h.patch
deleted file mode 100644
index 5247b5b..0000000
--- a/ci/my_config.h.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff -burp a/my_config.h b/my_config.h
---- a/my_config.h	2014-10-09 19:32:46.000000000 -0400
-+++ b/my_config.h	2014-10-09 19:35:12.000000000 -0400
-@@ -641,17 +641,4 @@
- #define SIZEOF_TIME_T 8
- /* #undef TIME_T_UNSIGNED */
-
--/*
--  stat structure (from <sys/stat.h>) is conditionally defined
--  to have different layout and size depending on the defined macros.
--  The correct macro is defined in my_config.h, which means it MUST be
--  included first (or at least before <features.h> - so, practically,
--  before including any system headers).
--
--  __GLIBC__ is defined in <features.h>
--*/
--#ifdef __GLIBC__
--#error <my_config.h> MUST be included first!
--#endif
--
- #endif
-
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index 9ebc832..71066ea 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.9'
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index 3183b08..fc29bc7 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -401,10 +401,10 @@
 		var row = locals[cdt][cdn];
 
 		frappe.model.set_value(cdt, cdn, "debit",
-			flt(flt(row.debit_in_account_currency)*row.exchange_rate), precision("debit", row));
+			flt(flt(row.debit_in_account_currency)*row.exchange_rate, precision("debit", row)));
 
 		frappe.model.set_value(cdt, cdn, "credit",
-			flt(flt(row.credit_in_account_currency)*row.exchange_rate), precision("credit", row));
+			flt(flt(row.credit_in_account_currency)*row.exchange_rate, precision("credit", row)));
 
 		cur_frm.cscript.update_totals(frm.doc);
 	},
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index b667c54..5f9a915 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/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json
index e916034..74a18fc 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.json
+++ b/erpnext/accounts/doctype/payment_request/payment_request.json
@@ -598,13 +598,13 @@
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "idx": 0, 
- "in_create": 0, 
+ "in_create": 1, 
  "in_dialog": 0, 
  "is_submittable": 1, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-02-24 16:49:46.832403", 
+ "modified": "2016-04-12 15:26:22.756129", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Payment Request", 
@@ -675,5 +675,6 @@
  "read_only": 0, 
  "read_only_onload": 0, 
  "sort_field": "modified", 
- "sort_order": "DESC"
+ "sort_order": "DESC", 
+ "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index bcb0503..32ad6d2 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -166,10 +166,7 @@
 
 cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
 	return {
-		query: "erpnext.controllers.queries.item_query",
-		filters:{
-			'is_purchase_item': 1
-		}
+		query: "erpnext.controllers.queries.item_query"
 	}
 }
 
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 2699f44..427e040 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -45,7 +45,6 @@
 			self.validate_supplier_invoice()
 			self.validate_advance_jv("Purchase Order")
 
-		self.check_active_purchase_items()
 		self.check_conversion_rate()
 		self.validate_credit_to_acc()
 		self.clear_unallocated_advances("Purchase Invoice Advance", "advances")
@@ -80,12 +79,6 @@
 			super(PurchaseInvoice, self).get_advances(self.credit_to, "Supplier", self.supplier,
 				"Purchase Invoice Advance", "advances", "debit_in_account_currency", "purchase_order")
 
-	def check_active_purchase_items(self):
-		for d in self.get('items'):
-			if d.item_code:		# extra condn coz item_code is not mandatory in PV
-				if frappe.db.get_value("Item", d.item_code, "is_purchase_item") != 1:
-					msgprint(_("Item {0} is not Purchase Item").format(d.item_code), raise_exception=True)
-
 	def check_conversion_rate(self):
 		default_currency = get_company_currency(self.company)
 		if not default_currency:
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 18faae7..62a9f52 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -10,11 +10,6 @@
 	order_by = ""
 	args = {"price_list": price_list}
 
-	if sales_or_purchase == "Sales":
-		condition = "i.is_sales_item=1"
-	else:
-		condition = "i.is_purchase_item=1"
-
 	if item:
 		# search serial no
 		item_code = frappe.db.sql("""select name as serial_no, item_code
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 9ffe8a9..bc1d73d 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -368,7 +368,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"""))
 
 
@@ -475,7 +475,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/doctype/tax_rule/tax_rule.js b/erpnext/accounts/doctype/tax_rule/tax_rule.js
index 4c35370..935ea62 100644
--- a/erpnext/accounts/doctype/tax_rule/tax_rule.js
+++ b/erpnext/accounts/doctype/tax_rule/tax_rule.js
@@ -19,19 +19,6 @@
 	frappe.ui.form.trigger("Tax Rule", "tax_type");
 })
 
-frappe.ui.form.on("Tax Rule", "use_for_shopping_cart", function(frm) {
-	if(!frm.doc.use_for_shopping_cart && 
-			(frappe.get_list("Tax Rule", {"use_for_shopping_cart":1}).length == 0)) {
-		frappe.model.get_value("Shopping Cart Settings", "Shopping Cart Settings", 
-				"enabled", function(docfield) {
-			if(docfield.enabled){
-				frm.set_value("use_for_shopping_cart", 1);
-				frappe.throw(__("Shopping Cart is enabled"));
-			}
-		});
-	}
-})
-
 frappe.ui.form.on("Tax Rule", "customer", function(frm) {
 	frappe.call({
 		method:"erpnext.accounts.doctype.tax_rule.tax_rule.get_party_details",
@@ -64,4 +51,4 @@
 			}
 		}
 	});
-});
\ No newline at end of file
+});
diff --git a/erpnext/accounts/doctype/tax_rule/tax_rule.py b/erpnext/accounts/doctype/tax_rule/tax_rule.py
index 7b62082..ce20d3a 100644
--- a/erpnext/accounts/doctype/tax_rule/tax_rule.py
+++ b/erpnext/accounts/doctype/tax_rule/tax_rule.py
@@ -6,7 +6,7 @@
 import frappe
 from frappe import _
 from frappe.model.document import Document
-from frappe.utils import cstr
+from frappe.utils import cstr, cint
 
 class IncorrectCustomerGroup(frappe.ValidationError): pass
 class IncorrectSupplierType(frappe.ValidationError): pass
@@ -20,15 +20,16 @@
 		self.validate_tax_template()
 		self.validate_date()
 		self.validate_filters()
+		self.validate_use_for_shopping_cart()
 
 	def validate_tax_template(self):
 		if self.tax_type== "Sales":
-			self.purchase_tax_template = self.supplier = self.supplier_type= None
+			self.purchase_tax_template = self.supplier = self.supplier_type = None
 			if self.customer:
 				self.customer_group = None
 
 		else:
-			self.sales_tax_template= self.customer = self.customer_group= None
+			self.sales_tax_template = self.customer = self.customer_group = None
 
 			if self.supplier:
 				self.supplier_type = None
@@ -81,6 +82,15 @@
 			if tax_rule[0].priority == self.priority:
 				frappe.throw(_("Tax Rule Conflicts with {0}".format(tax_rule[0].name)), ConflictingTaxRule)
 
+	def validate_use_for_shopping_cart(self):
+		'''If shopping cart is enabled and no tax rule exists for shopping cart, enable this one'''
+		if (not self.use_for_shopping_cart
+			and cint(frappe.db.get_single_value('Shopping Cart Settings', 'enabled'))
+			and not frappe.db.get_value('Tax Rule', {'use_for_shopping_cart': 1, 'name': ['!=', self.name]})):
+
+			self.use_for_shopping_cart = 1
+			frappe.msgprint(_("Enabling 'Use for Shopping Cart', as Shopping Cart is enabled and there should be at least one Tax Rule for Shopping Cart"))
+
 @frappe.whitelist()
 def get_party_details(party, party_type, args=None):
 	out = {}
@@ -109,11 +119,11 @@
 def get_tax_template(posting_date, args):
 	"""Get matching tax rule"""
 	args = frappe._dict(args)
-	conditions = ["""(from_date is null  or from_date = '' or from_date <= '{0}') 
+	conditions = ["""(from_date is null  or from_date = '' or from_date <= '{0}')
 		and (to_date is null  or to_date = '' or to_date >= '{0}')""".format(posting_date)]
 
 	for key, value in args.iteritems():
-		if key in "use_for_shopping_cart":
+		if key=="use_for_shopping_cart":
 			conditions.append("use_for_shopping_cart = {0}".format(1 if value else 0))
 		else:
 			conditions.append("ifnull({0}, '') in ('', '{1}')".format(key, frappe.db.escape(cstr(value))))
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index e4cba75..d348715 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -305,8 +305,12 @@
 	else:
 		args.update(get_party_details(party, party_type))
 
-	if party_type=="Customer":
+	if party_type in ("Customer", "Lead"):
 		args.update({"tax_type": "Sales"})
+
+		if party_type=='Lead':
+			args['customer'] = None
+			del args['lead']
 	else:
 		args.update({"tax_type": "Purchase"})
 
@@ -324,3 +328,10 @@
 			frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,'frozen_accounts_modifier')
 			if not frozen_accounts_modifier in frappe.get_roles():
 				frappe.throw(_("{0} {1} is frozen").format(party_type, party_name), PartyFrozen)
+
+def get_timeline_data(doctype, name):
+	'''returns timeline data for the past one year'''
+	from frappe.desk.form.load import get_communication_data
+	data = get_communication_data(doctype, name, fields = 'unix_timestamp(date(creation)), count(name)',
+		group_by='group by date(creation)', as_dict=False)
+	return dict(data)
\ No newline at end of file
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
index 69c88ed..712d35b 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
@@ -37,9 +37,12 @@
 						<br>{%= data[i][__("Voucher No")] %}</td>
 					<td>{%= data[i][__("Customer Name")] || data[i][__("Customer")] || data[i][__("Supplier Name")] || data[i][__("Supplier")] %}
 						<br>{%= __("Remarks") %}: {%= data[i][__("Remarks")] %}</td>
-					<td style="text-align: right">{%= format_currency(data[i][__("Invoiced Amount")]) %}</td>
-					<td style="text-align: right">{%= format_currency(data[i][__("Paid Amount")]) %}</td>
-					<td style="text-align: right">{%= format_currency(data[i][__("Outstanding Amount")]) %}</td>
+					<td style="text-align: right">
+						{%= format_currency(data[i][__("Invoiced Amount")], data[i]["currency"]) %}</td>
+					<td style="text-align: right">
+						{%= format_currency(data[i][__("Paid Amount")], data[i]["currency"]) %}</td>
+					<td style="text-align: right">
+						{%= format_currency(data[i][__("Outstanding Amount")], data[i]["currency"]) %}</td>
 				{% } else { %}
 					<td></td>
 					<td></td>
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 39fe5c4..365212a 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -58,21 +58,19 @@
 					"width": 120
 				})
 
+		columns.append({
+			"fieldname": "currency",
+			"label": _("Currency"),
+			"fieldtype": "Data",
+			"width": 100
+		})
 		if args.get("party_type") == "Customer":
 			columns += [_("Territory") + ":Link/Territory:80"]
 		if args.get("party_type") == "Supplier":
 			columns += [_("Supplier Type") + ":Link/Supplier Type:80"]
-		columns += [
-			{
-				"fieldname": "currency",
-				"label": _("Currency"),
-				"fieldtype": "Data",
-				"width": 100,
-				"hidden": 1
-			},
-			_("Remarks") + "::200"
-		]
-
+			
+		columns.append(_("Remarks") + "::200")
+		
 		return columns
 
 	def get_data(self, party_naming_by, args):
@@ -120,17 +118,17 @@
 					row += get_ageing_data(cint(self.filters.range1), cint(self.filters.range2),
 						cint(self.filters.range3), self.age_as_on, entry_date, outstanding_amount)
 
+					if self.filters.get(scrub(args.get("party_type"))):
+						row.append(gle.account_currency)
+					else:
+						row.append(company_currency)
+
 					# customer territory / supplier type
 					if args.get("party_type") == "Customer":
 						row += [self.get_territory(gle.party)]
 					if args.get("party_type") == "Supplier":
 						row += [self.get_supplier_type(gle.party)]
 
-					if self.filters.get(scrub(args.get("party_type"))):
-						row.append(gle.account_currency)
-					else:
-						row.append(company_currency)
-
 					row.append(gle.remarks)
 					data.append(row)
 
diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
index 60eade4..36e9734 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
@@ -18,18 +18,25 @@
 			columns += [ args.get("party_type") + " Name::140"]
 
 		columns += [
-			_("Total Invoiced Amt") + ":Currency:140",
-			_("Total Paid Amt") + ":Currency:140",
-			_("Total Outstanding Amt") + ":Currency:160",
-			"0-" + str(self.filters.range1) + ":Currency:100",
-			str(self.filters.range1) + "-" + str(self.filters.range2) + ":Currency:100",
-			str(self.filters.range2) + "-" + str(self.filters.range3) + ":Currency:100",
-			str(self.filters.range3) + _("-Above") + ":Currency:100"]
+			_("Total Invoiced Amt") + ":Currency/currency:140",
+			_("Total Paid Amt") + ":Currency/currency:140",
+			_("Total Outstanding Amt") + ":Currency/currency:160",
+			"0-" + str(self.filters.range1) + ":Currency/currency:100",
+			str(self.filters.range1) + "-" + str(self.filters.range2) + ":Currency/currency:100",
+			str(self.filters.range2) + "-" + str(self.filters.range3) + ":Currency/currency:100",
+			str(self.filters.range3) + _("-Above") + ":Currency/currency:100"]
 
 		if args.get("party_type") == "Customer":
 			columns += [_("Territory") + ":Link/Territory:80"]
 		if args.get("party_type") == "Supplier":
 			columns += [_("Supplier Type") + ":Link/Supplier Type:80"]
+			
+		columns.append({
+			"fieldname": "currency",
+			"label": _("Currency"),
+			"fieldtype": "Data",
+			"width": 80
+		})
 
 		return columns
 
@@ -53,6 +60,8 @@
 				row += [self.get_territory(party)]
 			if args.get("party_type") == "Supplier":
 				row += [self.get_supplier_type(party)]
+				
+			row.append(party_dict.currency)
 			data.append(row)
 
 		return data
@@ -73,6 +82,8 @@
 			)
 			for k in party_total[d.party].keys():
 				party_total[d.party][k] += d.get(k, 0)
+				
+			party_total[d.party].currency = d.currency
 
 		return party_total
 
@@ -90,7 +101,7 @@
 			cols += ["bill_no", "bill_date"]
 
 		cols += ["invoiced_amt", "paid_amt",
-		"outstanding_amt", "age", "range1", "range2", "range3", "range4"]
+		"outstanding_amt", "age", "range1", "range2", "range3", "range4", "currency"]
 
 		if args.get("party_type") == "Supplier":
 			cols += ["supplier_type", "remarks"]
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/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py
index ba87cf1..4ae0e67 100644
--- a/erpnext/accounts/report/gross_profit/gross_profit.py
+++ b/erpnext/accounts/report/gross_profit/gross_profit.py
@@ -145,11 +145,11 @@
 			self.data.append(row)
 
 		if self.grouped:
-			self.collapse_group()
+			self.get_average_rate_based_on_group_by()
 		else:
 			self.grouped_data = []
 
-	def collapse_group(self):
+	def get_average_rate_based_on_group_by(self):
 		# sum buying / selling totals for group
 		self.grouped_data = []
 		for key in self.grouped.keys():
@@ -166,6 +166,8 @@
 				if new_row.base_amount else 0
 			new_row.buying_rate = (new_row.buying_amount / new_row.qty) \
 				if new_row.qty else 0
+			new_row.base_rate = (new_row.base_amount / new_row.qty) \
+				if new_row.qty else 0
 
 			self.grouped_data.append(new_row)
 
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
index 7be5649..f1e706e 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
@@ -16,6 +16,14 @@
 	if item_list:
 		item_tax, tax_accounts = get_tax_accounts(item_list, columns)
 
+	columns.append({
+		"fieldname": "currency",
+		"label": _("Currency"),
+		"fieldtype": "Data",
+		"width": 80
+	})
+	company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
+	print company_currency
 	data = []
 	for d in item_list:
 		purchase_receipt = None
@@ -34,7 +42,7 @@
 			row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
 
 		total_tax = sum(row[last_col:])
-		row += [total_tax, d.base_net_amount + total_tax]
+		row += [total_tax, d.base_net_amount + total_tax, company_currency]
 
 		data.append(row)
 
@@ -48,7 +56,8 @@
 		"Supplier Name::120", "Payable Account:Link/Account:120", _("Project") + ":Link/Project:80",
 		_("Company") + ":Link/Company:100", _("Purchase Order") + ":Link/Purchase Order:100",
 		_("Purchase Receipt") + ":Link/Purchase Receipt:100", _("Expense Account") + ":Link/Account:140",
-		_("Qty") + ":Float:120", _("Rate") + ":Currency:120", _("Amount") + ":Currency:120"]
+		_("Qty") + ":Float:120", _("Rate") + ":Currency/currency:120", _("Amount") + ":Currency/currency:120"
+	]
 
 def get_conditions(filters):
 	conditions = ""
@@ -110,7 +119,7 @@
 					(tax_amount * d.base_net_amount) / d.base_net_total
 
 	tax_accounts.sort()
-	columns += [account_head + ":Currency:80" for account_head in tax_accounts]
-	columns += ["Total Tax:Currency:80", "Total:Currency:80"]
+	columns += [account_head + ":Currency/currency:80" for account_head in tax_accounts]
+	columns += ["Total Tax:Currency/currency:80", "Total:Currency/currency:80"]
 
 	return item_tax, tax_accounts
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
index e3c4753..2401202 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
@@ -14,7 +14,14 @@
 	item_list = get_items(filters)
 	if item_list:
 		item_tax, tax_accounts = get_tax_accounts(item_list, columns)
-
+	columns.append({
+		"fieldname": "currency",
+		"label": _("Currency"),
+		"fieldtype": "Data",
+		"width": 80
+	})
+	company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
+	
 	data = []
 	for d in item_list:
 		delivery_note = None
@@ -32,7 +39,7 @@
 			row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
 
 		total_tax = sum(row[last_col:])
-		row += [total_tax, d.base_net_amount + total_tax]
+		row += [total_tax, d.base_net_amount + total_tax, company_currency]
 
 		data.append(row)
 
@@ -48,7 +55,7 @@
 		_("Project") + ":Link/Project:80", _("Company") + ":Link/Company:100",
 		_("Sales Order") + ":Link/Sales Order:100", _("Delivery Note") + ":Link/Delivery Note:100",
 		_("Income Account") + ":Link/Account:140", _("Qty") + ":Float:120",
-		_("Rate") + ":Currency:120", _("Amount") + ":Currency:120"
+		_("Rate") + ":Currency/currency:120", _("Amount") + ":Currency/currency:120"
 	]
 
 def get_conditions(filters):
@@ -108,7 +115,7 @@
 					flt((tax_amount * d.base_net_amount) / d.base_net_total)
 
 	tax_accounts.sort()
-	columns += [account_head + ":Currency:80" for account_head in tax_accounts]
-	columns += ["Total Tax:Currency:80", "Total:Currency:80"]
+	columns += [account_head + ":Currency/currency:80" for account_head in tax_accounts]
+	columns += ["Total Tax:Currency/currency:80", "Total:Currency/currency:80"]
 
 	return item_tax, tax_accounts
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/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py
index c869803..7934bf2 100644
--- a/erpnext/accounts/report/purchase_register/purchase_register.py
+++ b/erpnext/accounts/report/purchase_register/purchase_register.py
@@ -21,6 +21,8 @@
 		invoice_expense_map, expense_accounts)
 	invoice_po_pr_map = get_invoice_po_pr_map(invoice_list)
 	supplier_details = get_supplier_deatils(invoice_list)
+	
+	company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
 
 	data = []
 	for inv in invoice_list:
@@ -32,7 +34,7 @@
 		row = [inv.name, inv.posting_date, inv.supplier, inv.supplier_name,
 			supplier_details.get(inv.supplier),
 			inv.credit_to, ", ".join(project), inv.bill_no, inv.bill_date, inv.remarks,
-			", ".join(purchase_order), ", ".join(purchase_receipt)]
+			", ".join(purchase_order), ", ".join(purchase_receipt), company_currency]
 
 		# map expense values
 		base_net_total = 0
@@ -62,10 +64,19 @@
 def get_columns(invoice_list):
 	"""return columns based on filters"""
 	columns = [
-		_("Invoice") + ":Link/Purchase Invoice:120", _("Posting Date") + ":Date:80", _("Supplier Id") + "::120",
-		_("Supplier Name") + "::120", _("Supplier Type") + ":Link/Supplier Type:120", _("Payable Account") + ":Link/Account:120",
-		_("Project") + ":Link/Project:80", _("Bill No") + "::120", _("Bill Date") + ":Date:80", _("Remarks") + "::150",
-		_("Purchase Order") + ":Link/Purchase Order:100", _("Purchase Receipt") + ":Link/Purchase Receipt:100"
+		_("Invoice") + ":Link/Purchase Invoice:120", 
+		_("Posting Date") + ":Date:80", _("Supplier Id") + "::120",
+		_("Supplier Name") + "::120", _("Supplier Type") + ":Link/Supplier Type:120", 
+		_("Payable Account") + ":Link/Account:120", _("Project") + ":Link/Project:80", 
+		_("Bill No") + "::120", _("Bill Date") + ":Date:80", _("Remarks") + "::150",
+		_("Purchase Order") + ":Link/Purchase Order:100", 
+		_("Purchase Receipt") + ":Link/Purchase Receipt:100",
+		{
+			"fieldname": "currency",
+			"label": _("Currency"),
+			"fieldtype": "Data",
+			"width": 80
+		}
 	]
 	expense_accounts = tax_accounts = expense_columns = tax_columns = []
 
@@ -84,14 +95,14 @@
 			', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
 
 
-	expense_columns = [(account + ":Currency:120") for account in expense_accounts]
+	expense_columns = [(account + ":Currency/currency:120") for account in expense_accounts]
 	for account in tax_accounts:
 		if account not in expense_accounts:
-			tax_columns.append(account + ":Currency:120")
+			tax_columns.append(account + ":Currency/currency:120")
 
-	columns = columns + expense_columns + [_("Net Total") + ":Currency:120"] + tax_columns + \
-		[_("Total Tax") + ":Currency:120", _("Grand Total") + ":Currency:120",
-			_("Rounded Total") + ":Currency:120", _("Outstanding Amount") + ":Currency:120"]
+	columns = columns + expense_columns + [_("Net Total") + ":Currency/currency:120"] + tax_columns + \
+		[_("Total Tax") + ":Currency/currency:120", _("Grand Total") + ":Currency/currency:120",
+			_("Rounded Total") + ":Currency/currency:120", _("Outstanding Amount") + ":Currency/currency:120"]
 
 	return columns, expense_accounts, tax_accounts
 
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/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py
index f68adad..d09cfc1 100644
--- a/erpnext/accounts/report/sales_register/sales_register.py
+++ b/erpnext/accounts/report/sales_register/sales_register.py
@@ -22,6 +22,7 @@
 
 	invoice_so_dn_map = get_invoice_so_dn_map(invoice_list)
 	customer_map = get_customer_deatils(invoice_list)
+	company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
 
 	data = []
 	for inv in invoice_list:
@@ -32,7 +33,8 @@
 		row = [inv.name, inv.posting_date, inv.customer, inv.customer_name,
 		customer_map.get(inv.customer, {}).get("customer_group"), 
 		customer_map.get(inv.customer, {}).get("territory"),
-		inv.debit_to, inv.project, inv.remarks, ", ".join(sales_order), ", ".join(delivery_note)]
+		inv.debit_to, inv.project, inv.remarks, 
+		", ".join(sales_order), ", ".join(delivery_note), company_currency]
 
 		# map income values
 		base_net_total = 0
@@ -66,7 +68,13 @@
 		_("Invoice") + ":Link/Sales Invoice:120", _("Posting Date") + ":Date:80", _("Customer Id") + "::120",
 		_("Customer Name") + "::120", _("Customer Group") + ":Link/Customer Group:120", _("Territory") + ":Link/Territory:80",
 		_("Receivable Account") + ":Link/Account:120", _("Project") +":Link/Project:80", _("Remarks") + "::150",
-		_("Sales Order") + ":Link/Sales Order:100", _("Delivery Note") + ":Link/Delivery Note:100"
+		_("Sales Order") + ":Link/Sales Order:100", _("Delivery Note") + ":Link/Delivery Note:100",
+		{
+			"fieldname": "currency",
+			"label": _("Currency"),
+			"fieldtype": "Data",
+			"width": 80
+		}
 	]
 
 	income_accounts = tax_accounts = income_columns = tax_columns = []
@@ -83,14 +91,14 @@
 			and parent in (%s) order by account_head""" %
 			', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
 
-	income_columns = [(account + ":Currency:120") for account in income_accounts]
+	income_columns = [(account + ":Currency/currency:120") for account in income_accounts]
 	for account in tax_accounts:
 		if account not in income_accounts:
-			tax_columns.append(account + ":Currency:120")
+			tax_columns.append(account + ":Currency/currency:120")
 
-	columns = columns + income_columns + [_("Net Total") + ":Currency:120"] + tax_columns + \
-		[_("Total Tax") + ":Currency:120", _("Grand Total") + ":Currency:120",
-		_("Rounded Total") + ":Currency:120", _("Outstanding Amount") + ":Currency:120"]
+	columns = columns + income_columns + [_("Net Total") + ":Currency/currency:120"] + tax_columns + \
+		[_("Total Tax") + ":Currency/currency:120", _("Grand Total") + ":Currency/currency:120",
+		_("Rounded Total") + ":Currency/currency:120", _("Outstanding Amount") + ":Currency/currency:120"]
 
 	return columns, income_accounts, tax_accounts
 
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 6dcc865..2f1959b 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -48,8 +48,7 @@
 				}
 			} else {
 				return{
-					query: "erpnext.controllers.queries.item_query",
-					filters: { 'is_purchase_item': 1 }
+					query: "erpnext.controllers.queries.item_query"
 				}
 			}
 		});
@@ -171,21 +170,10 @@
 			erpnext.buying.get_items_from_product_bundle(me.frm);
 		}, __("Get items from"));
 	},
-	
-	company: function() {
-		var me = this;
-		if (frappe.meta.get_docfield(this.frm.doctype, "shipping_address") 
-			&& !this.frm.doc.shipping_address) {
-				erpnext.utils.get_shipping_address(this.frm)
-		}
 
-		var company_doc = frappe.get_doc(":Company", me.frm.doc.company);
-		me.frm.set_value("letter_head", company_doc.default_letter_head);
-	},
-	
 	shipping_address: function(){
 		var me = this;
-		
+
 		this.frm.set_query("shipping_address", function(){
 			if(me.frm.doc.customer){
 				return{
@@ -203,8 +191,8 @@
 				}
 			}
 		});
-		
-		erpnext.utils.get_address_display(this.frm, "shipping_address", 
+
+		erpnext.utils.get_address_display(this.frm, "shipping_address",
 			"shipping_address_display", is_your_company_address=true)
 	}
 });
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py
index be704e9..1c3fe1e 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.py
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.py
@@ -57,7 +57,7 @@
 				if d.meta.get_field(x):
 					d.set(x, f_lst[x])
 
-			item = frappe.db.sql("""select is_stock_item, is_purchase_item,
+			item = frappe.db.sql("""select is_stock_item,
 				is_sub_contracted_item, end_of_life, disabled from `tabItem` where name=%s""",
 				d.item_code, as_dict=1)[0]
 
@@ -68,11 +68,6 @@
 			if item.is_stock_item==1 and d.qty and not d.warehouse:
 				frappe.throw(_("Warehouse is mandatory for stock Item {0} in row {1}").format(d.item_code, d.idx))
 
-			# validate purchase item
-			if obj.doctype=="Material Request" and getattr(obj, "material_request_type", None)=="Purchase":
-				if item.is_purchase_item != 1 and item.is_sub_contracted_item != 1:
-					frappe.throw(_("{0} must be a Purchased or Sub-Contracted Item in row {1}").format(d.item_code, d.idx))
-
 			items.append(cstr(d.item_code))
 
 		if items and len(items) != len(set(items)) and \
diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py
index 4b384fa..9a3d58c 100644
--- a/erpnext/buying/doctype/supplier/supplier.py
+++ b/erpnext/buying/doctype/supplier/supplier.py
@@ -8,7 +8,7 @@
 from frappe.model.naming import make_autoname
 from erpnext.utilities.address_and_contact import load_address_and_contact
 from erpnext.utilities.transaction_base import TransactionBase
-from erpnext.accounts.party import validate_party_accounts
+from erpnext.accounts.party import validate_party_accounts, get_timeline_data
 from erpnext.accounts.party_status import get_party_status
 
 class Supplier(TransactionBase):
@@ -84,3 +84,14 @@
 		frappe.db.sql("""update `tabAddress` set address_title=%(newdn)s
 			{set_field} where supplier=%(newdn)s"""\
 			.format(set_field=set_field), ({"newdn": newdn}))
+
+@frappe.whitelist()
+def get_dashboard_data(name):
+	'''load dashboard related data'''
+	frappe.has_permission(doc=frappe.get_doc('Supplier', name), throw=True)
+
+	from frappe.desk.notifications import get_open_count
+	return {
+		'count': get_open_count('Supplier', name),
+		'timeline_data': get_timeline_data('Supplier', name),
+	}
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/buying_controller.py b/erpnext/controllers/buying_controller.py
index 5361126..6a1b205 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -251,19 +251,6 @@
 
 		return self._sub_contracted_items
 
-	@property
-	def purchase_items(self):
-		if not hasattr(self, "_purchase_items"):
-			self._purchase_items = []
-			item_codes = list(set(item.item_code for item in
-				self.get("items")))
-			if item_codes:
-				self._purchase_items = [r[0] for r in frappe.db.sql("""select name
-					from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \
-					(", ".join((["%s"]*len(item_codes))),), item_codes)]
-
-		return self._purchase_items
-
 	def is_item_table_empty(self):
 		if not len(self.get("items")):
 			frappe.throw(_("Item table can not be blank"))
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index b40e6f4..f53ad53 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/selling_controller.py b/erpnext/controllers/selling_controller.py
index b8b2c31..3c9efa1 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -51,7 +51,10 @@
 
 		elif getattr(self, "lead", None):
 			from erpnext.crm.doctype.lead.lead import get_lead_details
-			self.update_if_missing(get_lead_details(self.lead))
+			self.update_if_missing(get_lead_details(
+				self.lead,
+				posting_date=self.get('transaction_date') or self.get('posting_date'),
+				company=self.company))
 
 	def set_price_list_and_item_details(self):
 		self.set_price_list_currency("Selling")
@@ -229,11 +232,10 @@
 def check_active_sales_items(obj):
 	for d in obj.get("items"):
 		if d.item_code:
-			item = frappe.db.sql("""select docstatus, is_sales_item,
+			item = frappe.db.sql("""select docstatus,
 				income_account from tabItem where name = %s""",
 				d.item_code, as_dict=True)[0]
-			if item.is_sales_item == 0:
-				frappe.throw(_("Item {0} must be a Sales Item in {1}").format(d.item_code, d.idx))
+                
 			if getattr(d, "income_account", None) and not item.income_account:
 				frappe.db.set_value("Item", d.item_code, "income_account",
 					d.income_account)
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 67cec8a..7210d76 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -288,8 +288,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):
@@ -324,22 +324,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):
@@ -402,13 +402,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))
@@ -422,21 +422,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"))
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index 497e8c7..0c3652f 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -10,6 +10,7 @@
 
 from erpnext.controllers.selling_controller import SellingController
 from erpnext.utilities.address_and_contact import load_address_and_contact
+from erpnext.accounts.party import set_taxes
 
 sender_field = "email_id"
 
@@ -140,7 +141,7 @@
 	return target_doc
 
 @frappe.whitelist()
-def get_lead_details(lead):
+def get_lead_details(lead, posting_date=None, company=None):
 	if not lead: return {}
 
 	from erpnext.accounts.party import set_address_details
@@ -160,4 +161,9 @@
 
 	set_address_details(out, lead, "Lead")
 
+	taxes_and_charges = set_taxes(None, 'Lead', posting_date, company,
+		billing_address=out.get('customer_address'), shipping_address=out.get('shipping_address_name'))
+	if taxes_and_charges:
+		out['taxes_and_charges'] = taxes_and_charges
+
 	return out
diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js
index a918cf3..884e9f4 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.js
+++ b/erpnext/crm/doctype/opportunity/opportunity.js
@@ -49,8 +49,7 @@
 
 		this.frm.set_query("item_code", "items", function() {
 			return {
-				query: "erpnext.controllers.queries.item_query",
-				filters: {"is_sales_item": 1}
+				query: "erpnext.controllers.queries.item_query"
 			};
 		});
 
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index fe4d0b6..be19aff 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.9"
 app_email = "info@erpnext.com"
 app_license = "GNU General Public License (v3)"
 source_link = "https://github.com/frappe/erpnext"
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index e769e3e..9e02baf 100755
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -157,6 +157,28 @@
 	def on_trash(self):
 		delete_events(self.doctype, self.name)
 
+	def get_timeline_data(self):
+		'''returns timeline data based on attendance'''
+		return
+
+@frappe.whitelist()
+def get_dashboard_data(name):
+	'''load dashboard related data'''
+	frappe.has_permission(doc=frappe.get_doc('Employee', name), throw=True)
+
+	from frappe.desk.notifications import get_open_count
+	return {
+		'count': get_open_count('Employee', name),
+		'timeline_data': get_timeline_data(name),
+	}
+
+def get_timeline_data(name):
+	'''Return timeline for attendance'''
+	return dict(frappe.db.sql('''select unix_timestamp(att_date), count(*)
+		from `tabAttendance` where employee=%s
+			and att_date > date_sub(curdate(), interval 1 year)
+			and status in ('Present', 'Half Day')
+			group by att_date''', name))
 
 @frappe.whitelist()
 def get_retirement_date(date_of_birth=None):
diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.py b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
index 6740c6e..331a82b 100755
--- a/erpnext/hr/doctype/leave_allocation/leave_allocation.py
+++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
@@ -77,7 +77,9 @@
 			frappe.throw(_("Total leaves allocated is mandatory"))
 
 	def validate_total_leaves_allocated(self):
-		if date_diff(self.to_date, self.from_date) <= flt(self.total_leaves_allocated):
+		# Adding a day to include To Date in the difference
+		date_difference = date_diff(self.to_date, self.from_date) + 1
+		if date_difference < self.total_leaves_allocated:
 			frappe.throw(_("Total allocated leaves are more than days in the period"), OverAllocationError)
 			
 	def validate_against_leave_applications(self):
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index f9f7377..63147d5 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -4,10 +4,11 @@
 from __future__ import unicode_literals
 import frappe
 
-from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, rounded, date_diff
+from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, rounded, date_diff, money_in_words
 from frappe.model.naming import make_autoname
 
 from frappe import msgprint, _
+from erpnext.accounts.utils import get_fiscal_year
 from erpnext.setup.utils import get_company_currency
 from erpnext.hr.utils import set_employee_name
 from erpnext.hr.doctype.process_payroll.process_payroll import get_month_details
@@ -18,6 +19,22 @@
 	def autoname(self):
 		self.name = make_autoname('Sal Slip/' +self.employee + '/.#####')
 
+	def validate(self):
+		self.check_existing()
+
+		if not (len(self.get("earnings")) or len(self.get("deductions"))):
+			self.get_emp_and_leave_details()
+		else:
+			self.get_leave_details(lwp = self.leave_without_pay)
+
+		if not self.net_pay:
+			self.calculate_net_pay()
+
+		company_currency = get_company_currency(self.company)
+		self.total_in_words = money_in_words(self.rounded_total, company_currency)
+
+		set_employee_name(self)
+
 	def get_emp_and_leave_details(self):
 		if self.employee:
 			joining_date, relieving_date = frappe.db.get_value("Employee", self.employee,
@@ -59,7 +76,9 @@
 
 	def get_leave_details(self, joining_date=None, relieving_date=None, lwp=None):
 		if not self.fiscal_year:
-			self.fiscal_year = frappe.db.get_default("fiscal_year")
+			# if default fiscal year is not set, get from nowdate
+			self.fiscal_year = get_fiscal_year(nowdate())[0]
+
 		if not self.month:
 			self.month = "%02d" % getdate(nowdate()).month
 
@@ -150,23 +169,6 @@
 			self.employee = ''
 			frappe.throw(_("Salary Slip of employee {0} already created for this month").format(self.employee))
 
-	def validate(self):
-		from frappe.utils import money_in_words
-		self.check_existing()
-
-		if not (len(self.get("earnings")) or len(self.get("deductions"))):
-			self.get_emp_and_leave_details()
-		else:
-			self.get_leave_details(lwp = self.leave_without_pay)
-
-		if not self.net_pay:
-			self.calculate_net_pay()
-
-		company_currency = get_company_currency(self.company)
-		self.total_in_words = money_in_words(self.rounded_total, company_currency)
-
-		set_employee_name(self)
-
 	def calculate_earning_total(self):
 		self.gross_pay = flt(self.arrear_amount) + flt(self.leave_encashment_amount)
 		for d in self.get("earnings"):
diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.py b/erpnext/hub_node/doctype/hub_settings/hub_settings.py
index 8522650..35f1f67 100644
--- a/erpnext/hub_node/doctype/hub_settings/hub_settings.py
+++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.py
@@ -24,7 +24,7 @@
 	def publish_selling_items(self):
 		"""Set `publish_in_hub`=1 for all Sales Items"""
 		for item in frappe.get_all("Item", fields=["name"],
-			filters={"is_sales_item": 1, "publish_in_hub": "0"}):
+			filters={ "publish_in_hub": "0"}):
 			frappe.db.set_value("Item", item.name, "publish_in_hub", 1)
 
 	def register(self):
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 94990fe..8779c49 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -15,8 +15,7 @@
 
 class BOM(Document):
 	def autoname(self):
-		names = frappe.db.sql("""select name from `tabBOM`
-			where item=%s""", self.item)
+		names = frappe.db.sql("""select name from `tabBOM` where item=%s""", self.item)
 
 		if names:
 			# name can be BOM/ITEM/001, BOM/ITEM/001-1, BOM-ITEM-001, BOM-ITEM-001-1
@@ -65,7 +64,7 @@
 		self.manage_default_bom()
 
 	def get_item_det(self, item_code):
-		item = frappe.db.sql("""select name, item_name, is_fixed_asset, is_purchase_item,
+		item = frappe.db.sql("""select name, item_name, is_fixed_asset,
 			docstatus, description, image, is_sub_contracted_item, stock_uom, default_bom,
 			last_purchase_rate
 			from `tabItem` where name=%s""", item_code, as_dict = 1)
@@ -119,7 +118,7 @@
 		rate = 0
 		if arg['bom_no']:
 			rate = self.get_bom_unitcost(arg['bom_no'])
-		elif arg and (arg['is_purchase_item'] == 1 or arg['is_sub_contracted_item'] == 1):
+		elif arg:
 			if self.rm_cost_as_per == 'Valuation Rate':
 				rate = self.get_valuation_rate(arg)
 			elif self.rm_cost_as_per == 'Last Purchase Rate':
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js
index 404ae38..d50fb46 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order.js
@@ -1,63 +1,98 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.ui.form.on("Production Order", "onload", function(frm) {
-	if (!frm.doc.status)
-		frm.doc.status = 'Draft';
+frappe.ui.form.on("Production Order", {
+	onload: function(frm) {
+		if (!frm.doc.status)
+			frm.doc.status = 'Draft';
 
-	frm.add_fetch("sales_order", "delivery_date", "expected_delivery_date");
-	frm.add_fetch("sales_order", "project", "project");
+		frm.add_fetch("sales_order", "delivery_date", "expected_delivery_date");
+		frm.add_fetch("sales_order", "project", "project");
 
-	if(frm.doc.__islocal) {
-		frm.set_value({
-			"actual_start_date": "",
-			"actual_end_date": ""
+		if(frm.doc.__islocal) {
+			frm.set_value({
+				"actual_start_date": "",
+				"actual_end_date": ""
+			});
+			erpnext.production_order.set_default_warehouse(frm);
+		}
+
+		erpnext.production_order.set_custom_buttons(frm);
+		erpnext.production_order.setup_company_filter(frm);
+		erpnext.production_order.setup_bom_filter(frm);
+	},
+	refresh: function(frm) {
+		erpnext.toggle_naming_series();
+		frm.set_intro("");
+		erpnext.production_order.set_custom_buttons(frm);
+
+		if (frm.doc.docstatus === 0 && !frm.doc.__islocal) {
+			frm.set_intro(__("Submit this Production Order for further processing."));
+		}
+
+		if (frm.doc.docstatus===1) {
+			frm.trigger('show_progress');
+		}
+	},
+	show_progress: function(frm) {
+		var bars = [];
+		var message = '';
+		var added_min = false;
+
+		// produced qty
+		var title = __('{0} items produced', [frm.doc.produced_qty]);
+		bars.push({
+			'title': title,
+			'width': (frm.doc.produced_qty / frm.doc.qty * 100) + '%',
+			'progress_class': 'progress-bar-success'
 		});
-		erpnext.production_order.set_default_warehouse(frm);
-	}
+		if(bars[0].width=='0%') {
+			 bars[0].width = '0.5%';
+			 added_min = 0.5;
+		 }
+		message = title;
 
-	erpnext.production_order.set_custom_buttons(frm);
-	erpnext.production_order.setup_company_filter(frm);
-	erpnext.production_order.setup_bom_filter(frm);
-});
-
-frappe.ui.form.on("Production Order", "refresh", function(frm) {
-	erpnext.toggle_naming_series();
-	frm.set_intro("");
-	erpnext.production_order.set_custom_buttons(frm);
-
-	if (frm.doc.docstatus === 0 && !frm.doc.__islocal) {
-		frm.set_intro(__("Submit this Production Order for further processing."));
+		// pending qty
+		var pending_complete = frm.doc.material_transferred_for_manufacturing - frm.doc.produced_qty;
+		if(pending_complete) {
+			var title = __('{0} items in progress', [pending_complete]);
+			bars.push({
+				'title': title,
+				'width': ((pending_complete / frm.doc.qty * 100) - added_min)  + '%',
+				'progress_class': 'progress-bar-warning'
+			})
+			message = message + '. ' + title;
+		}
+		frm.dashboard.add_progress(__('Status'), bars, message);
 	}
 });
 
-frappe.ui.form.on("Production Order", "additional_operating_cost", function(frm) {
-	erpnext.production_order.calculate_total_cost(frm);
-});
 
-frappe.ui.form.on("Production Order Operation", "workstation", function(frm, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	if (d.workstation) {
-		frappe.call({
-			"method": "frappe.client.get",
-			args: {
-				doctype: "Workstation",
-				name: d.workstation
-			},
-			callback: function (data) {
-				frappe.model.set_value(d.doctype, d.name, "hour_rate", data.message.hour_rate);
-				erpnext.production_order.calculate_cost(frm.doc);
-				erpnext.production_order.calculate_total_cost(frm);
-			}
-		})
+
+frappe.ui.form.on("Production Order Operation", {
+	workstation: function(frm, cdt, cdn) {
+		var d = locals[cdt][cdn];
+		if (d.workstation) {
+			frappe.call({
+				"method": "frappe.client.get",
+				args: {
+					doctype: "Workstation",
+					name: d.workstation
+				},
+				callback: function (data) {
+					frappe.model.set_value(d.doctype, d.name, "hour_rate", data.message.hour_rate);
+					erpnext.production_order.calculate_cost(frm.doc);
+					erpnext.production_order.calculate_total_cost(frm);
+				}
+			})
+		}
+	},
+	time_in_mins: function(frm, cdt, cdn) {
+		erpnext.production_order.calculate_cost(frm.doc);
+		erpnext.production_order.calculate_total_cost(frm);
 	}
 });
 
-frappe.ui.form.on("Production Order Operation", "time_in_mins", function(frm, cdt, cdn) {
-	erpnext.production_order.calculate_cost(frm.doc);
-	erpnext.production_order.calculate_total_cost(frm)
-});
-
 erpnext.production_order = {
 	set_custom_buttons: function(frm) {
 		var doc = frm.doc;
@@ -84,13 +119,20 @@
 			}
 
 			if (flt(doc.material_transferred_for_manufacturing) < flt(doc.qty)) {
-				frm.add_custom_button(__('Transfer Materials for Manufacture'),
-					cur_frm.cscript['Transfer Raw Materials'], __("Stock Entry"));
+				var btn = frm.add_custom_button(__('Start'),
+					cur_frm.cscript['Transfer Raw Materials']);
+				btn.addClass('btn-primary');
 			}
 
 			if (flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing)) {
-				frm.add_custom_button(__('Update Finished Goods'),
-					cur_frm.cscript['Update Finished Goods'], __("Stock Entry"));
+				var btn = frm.add_custom_button(__('Finish'),
+					cur_frm.cscript['Update Finished Goods']);
+
+				if(doc.material_transferred_for_manufacturing==doc.qty) {
+					// all materials transferred for manufacturing,
+					// make this primary
+					btn.addClass('btn-primary');
+				}
 			}
 		}
 
@@ -179,7 +221,7 @@
 			flt(this.frm.doc.qty) - flt(this.frm.doc.material_transferred_for_manufacturing);
 
 		frappe.prompt({fieldtype:"Int", label: __("Qty for {0}", [purpose]), fieldname:"qty",
-			description: __("Max: {0}", [max]) },
+			description: __("Max: {0}", [max]), 'default': max },
 			function(data) {
 				if(data.qty > max) {
 					frappe.msgprint(__("Quantity must not be more than {0}", [max]));
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 57eca4b..e482cc3 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -74,7 +74,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 = ""
@@ -84,7 +84,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"
 
@@ -105,7 +105,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")
@@ -122,7 +122,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:
@@ -131,7 +131,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
@@ -142,7 +142,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)
@@ -156,7 +156,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:
@@ -176,7 +176,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")
@@ -190,13 +190,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'):
@@ -204,7 +204,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))
 
@@ -216,17 +216,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]
@@ -250,14 +250,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),{})
@@ -278,7 +278,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
@@ -286,7 +286,7 @@
 			pass
 
 	def get_so_wise_planned_qty(self):
-		"""	
+		"""
 			bom_dict {
 				bom_no: ['sales_order', 'qty']
 			}
@@ -298,7 +298,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/patches.txt b/erpnext/patches.txt
index 975d589..469e327 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -261,3 +261,6 @@
 erpnext.patches.v6_20x.remove_customer_supplier_roles
 erpnext.patches.v6_24.rename_item_field
 erpnext.patches.v7_0.update_party_status
+erpnext.patches.v7_0.update_item_projected
+erpnext.patches.v6_20x.update_product_bundle_description
+erpnext.patches.v7_0.fix_duplicate_icons
diff --git a/erpnext/patches/v5_2/change_item_selects_to_checks.py b/erpnext/patches/v5_2/change_item_selects_to_checks.py
index 2665f4c..9871b6a 100644
--- a/erpnext/patches/v5_2/change_item_selects_to_checks.py
+++ b/erpnext/patches/v5_2/change_item_selects_to_checks.py
@@ -4,8 +4,7 @@
 
 def execute():
 	fields = ("is_stock_item", "is_asset_item", "has_batch_no", "has_serial_no",
-		"is_purchase_item", "is_sales_item", "inspection_required",
-		"is_pro_applicable", "is_sub_contracted_item")
+		"inspection_required", "is_pro_applicable", "is_sub_contracted_item")
 
 
 	# convert to 1 or 0
diff --git a/erpnext/patches/v6_20x/update_product_bundle_description.py b/erpnext/patches/v6_20x/update_product_bundle_description.py
new file mode 100644
index 0000000..1fac44b
--- /dev/null
+++ b/erpnext/patches/v6_20x/update_product_bundle_description.py
@@ -0,0 +1,11 @@
+from __future__ import unicode_literals
+import frappe
+from frappe.utils import sanitize_html
+
+def execute():
+	for product_bundle in frappe.get_all('Product Bundle'):
+		doc = frappe.get_doc('Product Bundle', product_bundle.name)
+		for item in doc.items:
+			if item.description:
+				description = sanitize_html(item.description)
+				item.db_set('description', description, update_modified=False)
diff --git a/erpnext/patches/v6_21/fix_reorder_level.py b/erpnext/patches/v6_21/fix_reorder_level.py
index 602978b..82a35eb 100644
--- a/erpnext/patches/v6_21/fix_reorder_level.py
+++ b/erpnext/patches/v6_21/fix_reorder_level.py
@@ -15,7 +15,7 @@
 				"warehouse": item.default_warehouse,
 				"warehouse_reorder_level": item.re_order_level,
 				"warehouse_reorder_qty": item.re_order_qty,
-				"material_request_type": "Purchase" if item_doc.is_purchase_item else "Transfer"
+				"material_request_type": "Purchase"
 			})
 
 			try:
diff --git a/erpnext/patches/v7_0/fix_duplicate_icons.py b/erpnext/patches/v7_0/fix_duplicate_icons.py
new file mode 100644
index 0000000..ee4c3e2
--- /dev/null
+++ b/erpnext/patches/v7_0/fix_duplicate_icons.py
@@ -0,0 +1,21 @@
+import frappe
+
+from frappe.desk.doctype.desktop_icon.desktop_icon import (sync_desktop_icons,
+	get_desktop_icons, set_hidden)
+
+def execute():
+	'''hide new style icons if old ones are set'''
+	sync_desktop_icons()
+
+	for user in frappe.get_all('User', filters={'user_type': 'System User'}):
+		desktop_icons = get_desktop_icons(user.name)
+		icons_dict = {}
+		for d in desktop_icons:
+			if not d.hidden:
+				icons_dict[d.module_name] = d
+
+		for key in (('Selling', 'Customer'), ('Stock', 'Item'), ('Buying', 'Supplier'),
+			('HR', 'Employee'), ('CRM', 'Lead'), ('Support', 'Issue'), ('Projects', 'Project')):
+			if key[0] in icons_dict and key[1] in icons_dict:
+				set_hidden(key[1], user.name, 1)
+
diff --git a/erpnext/patches/v7_0/update_item_projected.py b/erpnext/patches/v7_0/update_item_projected.py
new file mode 100644
index 0000000..71b54af
--- /dev/null
+++ b/erpnext/patches/v7_0/update_item_projected.py
@@ -0,0 +1,7 @@
+import frappe
+
+def execute():
+	frappe.reload_doctype("Item")
+	from erpnext.stock.doctype.bin.bin import update_item_projected_qty
+	for item in frappe.get_all("Item", filters={"is_stock_item": 1}):
+		update_item_projected_qty(item.name)
\ No newline at end of file
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 28a3691..78584fa 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -119,7 +119,7 @@
 
 	setup_sms: function() {
 		var me = this;
-		if(this.frm.doc.docstatus===1 && !in_list(["Lost", "Stopped"], this.frm.doc.status)
+		if(this.frm.doc.docstatus===1 && !in_list(["Lost", "Stopped", "Closed"], this.frm.doc.status)
 			&& this.frm.doctype != "Purchase Invoice") {
 			this.frm.page.add_menu_item(__('Send SMS'), function() { me.send_sms(); });
 		}
@@ -309,7 +309,15 @@
 
 		if (this.frm.doc.posting_date) var date = this.frm.doc.posting_date;
 		else var date = this.frm.doc.transaction_date;
-		set_party_account(set_pricing);
+		
+		if (frappe.meta.get_docfield(this.frm.doctype, "shipping_address") && 
+			in_list(['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'], this.frm.doctype)){
+				erpnext.utils.get_shipping_address(this.frm, function(){
+					set_party_account(set_pricing);
+				})
+		}else{
+			set_party_account(set_pricing);
+		}
 
 		if(this.frm.doc.company) {
 			erpnext.last_selected_company = this.frm.doc.company;
diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js
index 5e16dd8..2eb73a3 100644
--- a/erpnext/public/js/setup_wizard.js
+++ b/erpnext/public/js/setup_wizard.js
@@ -28,7 +28,6 @@
 						{"label": __("Manufacturing"), "value": "Manufacturing"},
 						{"label": __("Retail"), "value": "Retail"},
 						{"label": __("Services"), "value": "Services"},
-						{"label": __("Education"), "value": "Education"},
 						{"label": __("Other"), "value": "Other"},
 					], reqd:1},
 				{fieldname:'chart_of_accounts', label: __('Chart of Accounts'),
diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js
index 5f9a276..f5496ed 100644
--- a/erpnext/public/js/utils/party.js
+++ b/erpnext/public/js/utils/party.js
@@ -70,37 +70,57 @@
 				if(r.message) {
 					frm.set_value(display_field, r.message)
 				}
-
-				if(frappe.meta.get_docfield(frm.doc.doctype, "taxes") && !is_your_company_address) {
-					if(!erpnext.utils.validate_mandatory(frm, "Customer/Supplier",
-						frm.doc.customer || frm.doc.supplier, address_field)) return;
-
-					if(!erpnext.utils.validate_mandatory(frm, "Posting/Transaction Date",
-						frm.doc.posting_date || frm.doc.transaction_date, address_field)) return;
-				} else return;
-
-				frappe.call({
-					method: "erpnext.accounts.party.set_taxes",
-					args: {
-						"party": frm.doc.customer || frm.doc.supplier,
-						"party_type": (frm.doc.customer ? "Customer" : "Supplier"),
-						"posting_date": frm.doc.posting_date || frm.doc.transaction_date,
-						"company": frm.doc.company,
-						"billing_address": ((frm.doc.customer) ? (frm.doc.customer_address) : (frm.doc.supplier_address)),
-						"shipping_address": frm.doc.shipping_address_name
-					},
-					callback: function(r) {
-						if(r.message){
-							frm.set_value("taxes_and_charges", r.message)
-						}
-					}
-				});
+				erpnext.utils.set_taxes(frm, address_field, display_field, is_your_company_address);
 			}
 		})
 	} else {
 		frm.set_value(display_field, null);
 	}
+};
 
+erpnext.utils.set_taxes = function(frm, address_field, display_field, is_your_company_address) {
+	if(frappe.meta.get_docfield(frm.doc.doctype, "taxes") && !is_your_company_address) {
+		if(!erpnext.utils.validate_mandatory(frm, "Lead/Customer/Supplier",
+			frm.doc.customer || frm.doc.supplier || frm.doc.lead, address_field)) {
+				return;
+			}
+
+		if(!erpnext.utils.validate_mandatory(frm, "Posting/Transaction Date",
+			frm.doc.posting_date || frm.doc.transaction_date, address_field)) {
+			return;
+		}
+	} else {
+		return;
+	}
+
+	var party_type, party;
+	if (frm.doc.lead) {
+		party_type = 'Lead';
+		party = frm.doc.lead;
+	} else if (frm.doc.customer) {
+		party_type = 'Customer';
+		party = frm.doc.customer;
+	} else if (frm.doc.supplier) {
+		party_type = 'Supplier';
+		party = frm.doc.supplier;
+	}
+
+	frappe.call({
+		method: "erpnext.accounts.party.set_taxes",
+		args: {
+			"party": party,
+			"party_type": party_type,
+			"posting_date": frm.doc.posting_date || frm.doc.transaction_date,
+			"company": frm.doc.company,
+			"billing_address": ((frm.doc.customer || frm.doc.lead) ? (frm.doc.customer_address) : (frm.doc.supplier_address)),
+			"shipping_address": frm.doc.shipping_address_name
+		},
+		callback: function(r) {
+			if(r.message){
+				frm.set_value("taxes_and_charges", r.message)
+			}
+		}
+	});
 }
 
 erpnext.utils.get_contact_details = function(frm) {
@@ -128,7 +148,7 @@
 	return true;
 }
 
-erpnext.utils.get_shipping_address = function(frm){
+erpnext.utils.get_shipping_address = function(frm, callback){
 	frappe.call({
 		method: "erpnext.utilities.doctype.address.address.get_shipping_address",
 		args: {company: frm.doc.company},
@@ -137,6 +157,10 @@
 				frm.set_value("shipping_address", r.message[0]) //Address title or name
 				frm.set_value("shipping_address_display", r.message[1]) //Address to be displayed on the page
 			}
+
+			if(callback){
+				return callback();
+			}
 		}
 	});
 }
\ No newline at end of file
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 51aedef..591b9c1 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -10,7 +10,7 @@
 from frappe.desk.reportview import build_match_conditions
 from erpnext.utilities.transaction_base import TransactionBase
 from erpnext.utilities.address_and_contact import load_address_and_contact
-from erpnext.accounts.party import validate_party_accounts
+from erpnext.accounts.party import validate_party_accounts, get_timeline_data
 from erpnext.accounts.party_status import get_party_status
 
 class Customer(TransactionBase):
@@ -128,6 +128,18 @@
 			{set_field} where customer=%(newdn)s"""\
 			.format(set_field=set_field), ({"newdn": newdn}))
 
+
+@frappe.whitelist()
+def get_dashboard_data(name):
+	'''load dashboard related data'''
+	frappe.has_permission(doc=frappe.get_doc('Customer', name), throw=True)
+
+	from frappe.desk.notifications import get_open_count
+	return {
+		'count': get_open_count('Customer', name),
+		'timeline_data': get_timeline_data('Customer', name),
+	}
+
 def get_customer_list(doctype, txt, searchfield, start, page_len, filters):
 	if frappe.db.get_default("cust_master_name") == "Customer Name":
 		fields = ["name", "customer_group", "territory"]
@@ -174,7 +186,7 @@
 		select sum(base_grand_total*(100 - per_billed)/100)
 		from `tabSales Order`
 		where customer=%s and docstatus = 1 and company=%s
-		and per_billed < 100 and status != 'Stopped'""", (customer, company))
+		and per_billed < 100 and status != 'Closed'""", (customer, company))
 
 	outstanding_based_on_so = flt(outstanding_based_on_so[0][0]) if outstanding_based_on_so else 0.0
 
@@ -185,7 +197,7 @@
 		where
 			dn.name = dn_item.parent
 			and dn.customer=%s and dn.company=%s
-			and dn.docstatus = 1 and dn.status != 'Stopped'
+			and dn.docstatus = 1 and dn.status not in ('Closed', 'Stopped')
 			and ifnull(dn_item.against_sales_order, '') = ''
 			and ifnull(dn_item.against_sales_invoice, '') = ''""", (customer, company), as_dict=True)
 
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index 06f94fe..7c46983 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -94,7 +94,11 @@
 		var me = this;
 		frappe.call({
 			method: "erpnext.crm.doctype.lead.lead.get_lead_details",
-			args: { "lead": this.frm.doc.lead },
+			args: {
+				'lead': this.frm.doc.lead,
+				'posting_date': this.frm.doc.transaction_date,
+				'company': this.frm.doc.company,
+			},
 			callback: function(r) {
 				if(r.message) {
 					me.frm.updating_party_details = true;
@@ -166,4 +170,4 @@
 	var d = frappe.model.get_doc(cdt, cdn);
 	frappe.route_options = {"item_code": d.item_code};
 	frappe.set_route("query-report", "Stock Balance");
-})
\ No newline at end of file
+})
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 3c8add4..9cc7473 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -28,10 +28,6 @@
 	def validate_order_type(self):
 		super(Quotation, self).validate_order_type()
 
-		for d in self.get('items'):
-			if not frappe.db.get_value("Item", d.item_code, "is_sales_item"):
-				frappe.throw(_("Item {0} must be Sales Item").format(d.item_code))
-
 	def validate_quotation_to(self):
 		if self.customer:
 			self.quotation_to = "Customer"
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index 4ba6ff0..9d74e2a 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -238,9 +238,9 @@
 		from erpnext.stock.doctype.item.test_item import make_item
 		from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle
 
-		make_item("_Test Service Product Bundle", {"is_stock_item": 0, "is_pro_applicable": 0, "is_sales_item": 1})
-		make_item("_Test Service Product Bundle Item 1", {"is_stock_item": 0, "is_pro_applicable": 0, "is_sales_item": 1})
-		make_item("_Test Service Product Bundle Item 2", {"is_stock_item": 0, "is_pro_applicable": 0, "is_sales_item": 1})
+		make_item("_Test Service Product Bundle", {"is_stock_item": 0, "is_pro_applicable": 0})
+		make_item("_Test Service Product Bundle Item 1", {"is_stock_item": 0, "is_pro_applicable": 0})
+		make_item("_Test Service Product Bundle Item 2", {"is_stock_item": 0, "is_pro_applicable": 0})
 
 		make_product_bundle("_Test Service Product Bundle",
 			["_Test Service Product Bundle Item 1", "_Test Service Product Bundle Item 2"])
@@ -254,9 +254,9 @@
 		from erpnext.stock.doctype.item.test_item import make_item
 		from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle
 
-		make_item("_Test Mix Product Bundle", {"is_stock_item": 0, "is_pro_applicable": 0, "is_sales_item": 1})
-		make_item("_Test Mix Product Bundle Item 1", {"is_stock_item": 1, "is_sales_item": 1})
-		make_item("_Test Mix Product Bundle Item 2", {"is_stock_item": 0, "is_pro_applicable": 0, "is_sales_item": 1})
+		make_item("_Test Mix Product Bundle", {"is_stock_item": 0, "is_pro_applicable": 0})
+		make_item("_Test Mix Product Bundle Item 1", {"is_stock_item": 1})
+		make_item("_Test Mix Product Bundle Item 2", {"is_stock_item": 0, "is_pro_applicable": 0})
 
 		make_product_bundle("_Test Mix Product Bundle",
 			["_Test Mix Product Bundle Item 1", "_Test Mix Product Bundle Item 2"])
@@ -265,7 +265,7 @@
 
 	def test_auto_insert_price(self):
 		from erpnext.stock.doctype.item.test_item import make_item
-		make_item("_Test Item for Auto Price List", {"is_stock_item": 0, "is_pro_applicable": 0, "is_sales_item": 1})
+		make_item("_Test Item for Auto Price List", {"is_stock_item": 0, "is_pro_applicable": 0})
 		frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 1)
 
 		item_price = frappe.db.get_value("Item Price", {"price_list": "_Test Price List",
@@ -299,14 +299,13 @@
 		from erpnext.stock.doctype.item.test_item import make_item
 		from erpnext.buying.doctype.purchase_order.purchase_order import update_status
 
-		po_item = make_item("_Test Item for Drop Shipping", {"is_stock_item": 1, "is_sales_item": 1,
-			"is_purchase_item": 1, "delivered_by_supplier": 1, 'default_supplier': '_Test Supplier',
+		po_item = make_item("_Test Item for Drop Shipping", {"is_stock_item": 1, "delivered_by_supplier": 1, 
+        'default_supplier': '_Test Supplier',
 		    "expense_account": "_Test Account Cost for Goods Sold - _TC",
 		    "cost_center": "_Test Cost Center - _TC"
 			})
 
-		dn_item = make_item("_Test Regular Item", {"is_stock_item": 1, "is_sales_item": 1,
-			"is_purchase_item": 1, "expense_account": "_Test Account Cost for Goods Sold - _TC",
+		dn_item = make_item("_Test Regular Item", {"is_stock_item": 1, "expense_account": "_Test Account Cost for Goods Sold - _TC",
   		  	"cost_center": "_Test Cost Center - _TC"})
 
 		so_items = [
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/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.json b/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.json
index 6b19b63..a0a7505 100644
--- a/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.json
+++ b/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.json
@@ -7,12 +7,12 @@
  "doctype": "Report", 
  "idx": 1, 
  "is_standard": "Yes", 
- "modified": "2015-10-06 12:43:48.259027", 
+ "modified": "2016-04-12 18:45:49.733159", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Pending SO Items For Purchase Request", 
  "owner": "Administrator", 
- "query": "select  so_item.item_code as \"Item Code:Link/Item:120\",\n so_item.item_name as \"Item Name::120\",\n so_item.description as \"Description::120\",\n so.`name` as \"S.O. No.:Link/Sales Order:120\",\n so.`transaction_date` as \"Date:Date:120\",\n mr.name as \"Material Request:Link/Material Request:120\",\n so.customer as \"Customer:Link/Customer:120\",\n so.territory as \"Terretory:Link/Territory:120\",\n sum(so_item.qty) as \"SO Qty:Float:100 \",\n sum(mr_item.qty) as \"Requested Qty:Float:100\",\n sum(so_item.qty) - sum(mr_item.qty) as \"Pending Qty:Float:100 \", \n so.company as \"Company:Link/Company:\"\nfrom\n `tabSales Order` so, `tabSales Order Item` so_item, \n `tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere \n so_item.`parent` = so.`name` \n and mr_item.parent = mr.name\n and mr_item.sales_order = so.name\n and mr_item.item_code = so_item.item_code\n and so.docstatus = 1 and so.status != \"Stopped\" \n and mr.docstatus = 1 and mr.status != \"Stopped\"\ngroup by so.name, so_item.item_code\nhaving sum(so_item.qty) > sum(mr_item.qty)\norder by so.name desc, so_item.item_code asc", 
+ "query": "select  so_item.item_code as \"Item Code:Link/Item:120\",\n so_item.item_name as \"Item Name::120\",\n so_item.description as \"Description::120\",\n so.`name` as \"S.O. No.:Link/Sales Order:120\",\n so.`transaction_date` as \"Date:Date:120\",\n mr.name as \"Material Request:Link/Material Request:120\",\n so.customer as \"Customer:Link/Customer:120\",\n so.territory as \"Terretory:Link/Territory:120\",\n sum(so_item.qty) as \"SO Qty:Float:100 \",\n sum(mr_item.qty) as \"Requested Qty:Float:100\",\n sum(so_item.qty) - sum(mr_item.qty) as \"Pending Qty:Float:100 \", \n so.company as \"Company:Link/Company:\"\nfrom\n `tabSales Order` so, `tabSales Order Item` so_item, \n `tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere \n so_item.`parent` = so.`name` \n and mr_item.parent = mr.name\n and mr_item.sales_order = so.name\n and mr_item.item_code = so_item.item_code\n and so.docstatus = 1 and so.status != \"Closed\" \n and mr.docstatus = 1 and mr.status != \"Stopped\"\ngroup by so.name, so_item.item_code\nhaving sum(so_item.qty) > sum(mr_item.qty)\norder by so.name desc, so_item.item_code asc", 
  "ref_doctype": "Sales Order", 
  "report_name": "Pending SO Items For Purchase Request", 
  "report_type": "Query Report"
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index bfefb9f..607aa41 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -55,8 +55,7 @@
 		if(this.frm.fields_dict["items"].grid.get_field('item_code')) {
 			this.frm.set_query("item_code", "items", function() {
 				return {
-					query: "erpnext.controllers.queries.item_query",
-					filters: {'is_sales_item': 1}
+					query: "erpnext.controllers.queries.item_query"
 				}
 			});
 		}
diff --git a/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.html b/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.html
index 5fe7a14..fe8a963 100644
--- a/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.html
+++ b/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.html
@@ -21,7 +21,7 @@
 			<h3>{%= __("Next Steps") %}</h3>
 			<ul class="list-unstyled">
 				<li><a class="text-muted" href="#">{%= __("Go to the Desktop and start using ERPNext") %}</a></li>
-				<li><a class="text-muted" href="#Module/Learn">{%= __("View a list of all the help videos") %}</a></li>
+				<li><a class="text-muted" href="#modules/Learn">{%= __("View a list of all the help videos") %}</a></li>
 				<li><a class="text-muted" href="https://manual.erpnext.com" target="_blank">{%= __("Read the ERPNext Manual") %}</a></li>
 				<li><a class="text-muted" href="https://discuss.erpnext.com" target="_blank">{%= __("Community Forum") %}</a></li>
 			</ul>
diff --git a/erpnext/setup/setup_wizard/sample_data.py b/erpnext/setup/setup_wizard/sample_data.py
index 63fc2e7..8078ebc 100644
--- a/erpnext/setup/setup_wizard/sample_data.py
+++ b/erpnext/setup/setup_wizard/sample_data.py
@@ -11,26 +11,25 @@
 def make_sample_data():
 	"""Create a few opportunities, quotes, material requests, issues, todos, projects
 	to help the user get started"""
+	items = frappe.get_all("Item")
 
-	selling_items = frappe.get_all("Item", filters = {"is_sales_item": 1})
-	buying_items = frappe.get_all("Item", filters = {"is_purchase_item": 1})
 	customers = frappe.get_all("Customer")
 	warehouses = frappe.get_all("Warehouse")
 
-	if selling_items and customers:
+	if items and customers:
 		for i in range(3):
 			customer = random.choice(customers).name
-			make_opportunity(selling_items, customer)
-			make_quote(selling_items, customer)
+			make_opportunity(items, customer)
+			make_quote(items, customer)
 
 	make_projects()
 
-	if buying_items and warehouses:
-		make_material_request(buying_items)
+	if items and warehouses:
+		make_material_request(items)
 
 	frappe.db.commit()
 
-def make_opportunity(selling_items, customer):
+def make_opportunity(items, customer):
 	b = frappe.get_doc({
 		"doctype": "Opportunity",
 		"enquiry_from": "Customer",
@@ -39,16 +38,16 @@
 		"with_items": 1
 	})
 
-	add_random_children(b, "items", rows=len(selling_items), randomize = {
+	add_random_children(b, "items", rows=len(items), randomize = {
 		"qty": (1, 5),
-		"item_code": ("Item", {"is_sales_item": 1})
+		"item_code": ["Item"]
 	}, unique="item_code")
 
 	b.insert(ignore_permissions=True)
 
 	b.add_comment('Comment', text="This is a dummy record")
 
-def make_quote(selling_items, customer):
+def make_quote(items, customer):
 	qtn = frappe.get_doc({
 		"doctype": "Quotation",
 		"quotation_to": "Customer",
@@ -56,17 +55,17 @@
 		"order_type": "Sales"
 	})
 
-	add_random_children(qtn, "items", rows=len(selling_items), randomize = {
+	add_random_children(qtn, "items", rows=len(items), randomize = {
 		"qty": (1, 5),
-		"item_code": ("Item", {"is_sales_item": 1})
+		"item_code": ["Item"]
 	}, unique="item_code")
 
 	qtn.insert(ignore_permissions=True)
 
 	qtn.add_comment('Comment', text="This is a dummy record")
 
-def make_material_request(buying_items):
-	for i in buying_items:
+def make_material_request(items):
+	for i in items:
 		mr = frappe.get_doc({
 			"doctype": "Material Request",
 			"material_request_type": "Purchase",
diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py
index 864d2d0..780fa97 100644
--- a/erpnext/setup/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/setup_wizard/setup_wizard.py
@@ -46,7 +46,7 @@
 		try:
 			make_sample_data()
 			frappe.clear_cache()
-		except FiscalYearError:
+		except:
 			# clear message
 			if frappe.message_log:
 				frappe.message_log.pop()
@@ -291,8 +291,6 @@
 					"item_code": item,
 					"item_name": item,
 					"description": item,
-					"is_sales_item": 1 if is_sales_item else 0,
-					"is_purchase_item": 1 if is_purchase_item else 0,
 					"show_in_website": 1,
 					"is_stock_item": is_stock_item and 1 or 0,
 					"is_pro_applicable": is_pro_applicable and 1 or 0,
@@ -426,7 +424,7 @@
 	# create employee for self
 	emp = frappe.get_doc({
 		"doctype": "Employee",
-		"full_name": " ".join(filter(None, [args.get("first_name"), args.get("last_name")])),
+		"employee_name": " ".join(filter(None, [args.get("first_name"), args.get("last_name")])),
 		"user_id": frappe.session.user,
 		"status": "Active",
 		"company": args.get("company_name")
@@ -470,7 +468,7 @@
 				# create employee
 				emp = frappe.get_doc({
 					"doctype": "Employee",
-					"full_name": fullname,
+					"employee_name": fullname,
 					"user_id": email,
 					"status": "Active",
 					"company": args.get("company_name")
diff --git a/erpnext/startup/notifications.py b/erpnext/startup/notifications.py
index 700ced2..335efbb 100644
--- a/erpnext/startup/notifications.py
+++ b/erpnext/startup/notifications.py
@@ -10,6 +10,7 @@
 			"Warranty Claim": {"status": "Open"},
 			"Task": {"status": "Overdue"},
 			"Project": {"status": "Open"},
+			"Item": {"total_projected_qty": ("<", 0)},
 			"Customer": {"status": "Open"},
 			"Supplier": {"status": "Open"},
 			"Lead": {"status": "Open"},
@@ -40,7 +41,7 @@
 				"docstatus": ("<", 2)
 			},
 			"Purchase Receipt": {"docstatus": 0},
-			"Production Order": { "status": "In Process" },
+			"Production Order": { "status": ("in", ("Draft", "Not Started", "In Process")) },
 			"BOM": {"docstatus": 0},
 			"Timesheet": {"docstatus": 0},
 			"Time Log": {"status": "Draft"},
diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py
index 1682686..ae7c6e7 100644
--- a/erpnext/stock/doctype/bin/bin.py
+++ b/erpnext/stock/doctype/bin/bin.py
@@ -69,6 +69,7 @@
 		 	flt(self.indented_qty) + flt(self.planned_qty) - flt(self.reserved_qty)
 
 		self.save()
+		update_item_projected_qty(self.item_code)
 
 	def get_first_sle(self):
 		sle = frappe.db.sql("""
@@ -79,3 +80,9 @@
 			limit 1
 		""", (self.item_code, self.warehouse), as_dict=1)
 		return sle and sle[0] or None
+
+def update_item_projected_qty(item_code):
+	'''Set Item project qty'''
+	frappe.db.sql('''update tabItem set
+		total_projected_qty = ifnull((select sum(projected_qty) from tabBin where item_code=%s), 0)
+		where name=%s''', (item_code, item_code))
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index 8a9d83c..900c40c 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -16,6 +16,12 @@
 
 	},
 
+	dashboard_update: function(frm) {
+		if(frm.dashboard_data.stock_data && frm.dashboard_data.stock_data.length) {
+			frm.dashboard.add_stats(frappe.render_template('item_dashboard', {data: frm.dashboard_data.stock_data}))
+		}
+	},
+
 	refresh: function(frm) {
 
 		if(frm.doc.is_stock_item) {
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 94d2e8d..b9b5569 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -930,35 +930,6 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "default": "1", 
-   "description": "", 
-   "fieldname": "is_purchase_item", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "label": "Is Purchase Item", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "is_purchase_item", 
-   "oldfieldtype": "Select", 
-   "options": "", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
    "default": "0.00", 
    "depends_on": "is_stock_item", 
    "description": "", 
@@ -988,7 +959,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_purchase_item", 
+   "depends_on": "", 
    "description": "Average time taken by the supplier to deliver", 
    "fieldname": "lead_time_days", 
    "fieldtype": "Int", 
@@ -1016,7 +987,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_purchase_item", 
+   "depends_on": "", 
    "description": "", 
    "fieldname": "buying_cost_center", 
    "fieldtype": "Link", 
@@ -1045,7 +1016,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_purchase_item", 
+   "depends_on": "", 
    "description": "", 
    "fieldname": "expense_account", 
    "fieldtype": "Link", 
@@ -1074,7 +1045,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_purchase_item", 
+   "depends_on": "", 
    "fieldname": "unit_of_measure_conversion", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -1100,7 +1071,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_purchase_item", 
+   "depends_on": "", 
    "description": "Will also apply for variants", 
    "fieldname": "uoms", 
    "fieldtype": "Table", 
@@ -1129,7 +1100,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_purchase_item", 
+   "depends_on": "", 
    "fieldname": "last_purchase_rate", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -1156,7 +1127,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
-   "depends_on": "is_purchase_item", 
+   "depends_on": "", 
    "fieldname": "supplier_details", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -1182,7 +1153,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "eval:doc.is_purchase_item", 
+   "depends_on": "", 
    "fieldname": "default_supplier", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1233,7 +1204,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "eval:doc.is_purchase_item", 
+   "depends_on": "", 
    "fieldname": "manufacturer", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1259,7 +1230,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "eval:doc.is_purchase_item", 
+   "depends_on": "", 
    "fieldname": "manufacturer_part_no", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -1284,7 +1255,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_purchase_item", 
+   "depends_on": "", 
    "fieldname": "column_break2", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -1311,7 +1282,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_purchase_item", 
+   "depends_on": "", 
    "fieldname": "supplier_items", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -1363,65 +1334,6 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "default": "1", 
-   "description": "", 
-   "fieldname": "is_sales_item", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 1, 
-   "in_list_view": 0, 
-   "label": "Is Sales Item", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "is_sales_item", 
-   "oldfieldtype": "Select", 
-   "options": "", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "default": "", 
-   "depends_on": "eval:doc.is_sales_item", 
-   "description": "Allow in Sales Order of type \"Service\"", 
-   "fieldname": "is_service_item", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 1, 
-   "in_list_view": 0, 
-   "label": "Is Service Item", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "is_service_item", 
-   "oldfieldtype": "Select", 
-   "options": "", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
    "default": "0", 
    "description": "Publish Item to hub.erpnext.com", 
    "fieldname": "publish_in_hub", 
@@ -1475,7 +1387,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_sales_item", 
+   "depends_on": "", 
    "fieldname": "income_account", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1501,7 +1413,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_sales_item", 
+   "depends_on": "", 
    "fieldname": "selling_cost_center", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -1527,7 +1439,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_sales_item", 
+   "depends_on": "", 
    "fieldname": "column_break3", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -1554,7 +1466,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "is_sales_item", 
+   "depends_on": "", 
    "description": "", 
    "fieldname": "customer_items", 
    "fieldtype": "Table", 
@@ -1581,7 +1493,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "eval:doc.is_sales_item", 
+   "depends_on": "", 
    "fieldname": "max_discount", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -2285,6 +2197,31 @@
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "total_projected_qty", 
+   "fieldtype": "Float", 
+   "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Total Projected Qty", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }
  ], 
  "hide_heading": 0, 
@@ -2298,7 +2235,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 1, 
- "modified": "2016-04-11 09:15:30.911215", 
+ "modified": "2016-04-15 11:18:48.948958", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Item", 
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 8286b5f..2f92dd9 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -50,12 +50,11 @@
 		self.name = self.item_code
 
 	def before_insert(self):
-		if self.is_sales_item=="Yes":
-			self.publish_in_hub = 1
-
 		if not self.description:
 			self.description = self.item_name
 
+		self.publish_in_hub = 1
+        
 	def validate(self):
 		super(Item, self).validate()
 
@@ -71,7 +70,6 @@
 		self.check_item_tax()
 		self.validate_barcode()
 		self.cant_change()
-		self.validate_reorder_level()
 		self.validate_warehouse_for_reorder()
 		self.update_item_desc()
 		self.synced_with_hub = 0
@@ -407,21 +405,16 @@
 					if self.check_if_linked_document_exists():
 						frappe.throw(_("As there are existing transactions for this item, \
 							you can not change the values of 'Has Serial No', 'Has Batch No', 'Is Stock Item' and 'Valuation Method'"))
-							
+
 	def check_if_linked_document_exists(self):
-		for doctype in ("Sales Order Item", "Delivery Note Item", "Sales Invoice Item", 
-			"Material Request Item", "Purchase Order Item", "Purchase Receipt Item", 
+		for doctype in ("Sales Order Item", "Delivery Note Item", "Sales Invoice Item",
+			"Material Request Item", "Purchase Order Item", "Purchase Receipt Item",
 			"Purchase Invoice Item", "Stock Entry Detail", "Stock Reconciliation Item"):
 			if frappe.db.get_value(doctype, filters={"item_code": self.name, "docstatus": 1}) or \
-				frappe.db.get_value("Production Order", 
+				frappe.db.get_value("Production Order",
 					filters={"production_item": self.name, "docstatus": 1}):
 				return True
 
-	def validate_reorder_level(self):
-		if len(self.get("reorder_levels", {"material_request_type": "Purchase"})):
-			if not (self.is_purchase_item or self.is_pro_applicable):
-				frappe.throw(_("""To set reorder level, item must be a Purchase Item or Manufacturing Item"""))
-
 		for d in self.get("reorder_levels"):
 			if d.warehouse_reorder_level and not d.warehouse_reorder_qty:
 				frappe.throw(_("Row #{0}: Please set reorder quantity").format(d.idx))
@@ -583,6 +576,30 @@
 		if self.is_fixed_asset and self.is_stock_item:
 			frappe.throw(_("Fixed Asset Item must be a non-stock item"))
 
+
+@frappe.whitelist()
+def get_dashboard_data(name):
+	'''load dashboard related data'''
+	frappe.has_permission(doc=frappe.get_doc('Item', name), throw=True)
+
+	from frappe.desk.notifications import get_open_count
+	return {
+		'count': get_open_count('Item', name),
+		'timeline_data': get_timeline_data(name),
+		'stock_data': get_stock_data(name)
+	}
+
+def get_timeline_data(name):
+	'''returns timeline data based on stock ledger entry'''
+	return dict(frappe.db.sql('''select unix_timestamp(posting_date), count(*)
+		from `tabStock Ledger Entry` where item_code=%s
+			and posting_date > date_sub(curdate(), interval 1 year)
+			group by posting_date''', name))
+
+def get_stock_data(name):
+	return frappe.get_all('Bin', fields=['warehouse', 'actual_qty', 'projected_qty'],
+		filters={'item_code': name})
+
 def validate_end_of_life(item_code, end_of_life=None, disabled=None, verbose=1):
 	if (not end_of_life) or (disabled is None):
 		end_of_life, disabled = frappe.db.get_value("Item", item_code, ["end_of_life", "disabled"])
diff --git a/erpnext/stock/doctype/item/item_dashboard.html b/erpnext/stock/doctype/item/item_dashboard.html
new file mode 100644
index 0000000..a002a50
--- /dev/null
+++ b/erpnext/stock/doctype/item/item_dashboard.html
@@ -0,0 +1,12 @@
+<div style="padding-left: 15px;">
+	<h5>Stock Levels</h5>
+	<div class="row">
+		<div class="col-md-6 col-xs-12">
+			<ul class="list-unstyled">
+			{% data.every(function(d) { %}
+				<li class="small">{{ d.warehouse }}: {{ d.actual_qty }} ({{ d.projected_qty }})</li>
+			{% }) %}
+			</ul>
+		</div>
+	</div>
+</div>
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item/item_links.py b/erpnext/stock/doctype/item/item_links.py
index c1fff8c..5586214 100644
--- a/erpnext/stock/doctype/item/item_links.py
+++ b/erpnext/stock/doctype/item/item_links.py
@@ -4,7 +4,8 @@
 	'fieldname': 'item_code',
 	'non_standard_fieldnames': {
 		'Production Order': 'production_item',
-		'Product Bundle': 'new_item_code'
+		'Product Bundle': 'new_item_code',
+		'Batch': 'item'
 	},
 	'transactions': [
 		{
diff --git a/erpnext/stock/doctype/item/item_list.js b/erpnext/stock/doctype/item/item_list.js
index fffc7fe..2fee589 100644
--- a/erpnext/stock/doctype/item/item_list.js
+++ b/erpnext/stock/doctype/item/item_list.js
@@ -1,10 +1,12 @@
 frappe.listview_settings['Item'] = {
 	add_fields: ["item_name", "stock_uom", "item_group", "image", "variant_of",
-		"has_variants", "end_of_life", "disabled", "is_sales_item"],
+		"has_variants", "end_of_life", "disabled", "total_projected_qty"],
 	filters: [["disabled", "=", "0"]],
 
 	get_indicator: function(doc) {
-		if (doc.disabled) {
+		if(doc.total_projected_qty < 0) {
+			return [__("Shortage"), "red", "total_projected_qty,<,0"];
+		} else if (doc.disabled) {
 			return [__("Disabled"), "grey", "disabled,=,Yes"];
 		} else if (doc.end_of_life && doc.end_of_life < frappe.datetime.get_today()) {
 			return [__("Expired"), "grey", "end_of_life,<,Today"];
@@ -12,8 +14,6 @@
 			return [__("Template"), "blue", "has_variants,=,Yes"];
 		} else if (doc.variant_of) {
 			return [__("Variant"), "green", "variant_of,=," + doc.variant_of];
-		} else {
-			return [__("Active"), "blue", "end_of_life,>=,Today"];
 		}
 	}
 };
diff --git a/erpnext/stock/doctype/item/test_records.json b/erpnext/stock/doctype/item/test_records.json
index 91a7493..03b6198 100644
--- a/erpnext/stock/doctype/item/test_records.json
+++ b/erpnext/stock/doctype/item/test_records.json
@@ -11,8 +11,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 0,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 1,
   "is_sub_contracted_item": 0,
   "item_code": "_Test Item",
@@ -43,8 +41,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 0,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 1,
   "is_sub_contracted_item": 0,
   "item_code": "_Test Item 2",
@@ -66,8 +62,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 0,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 1,
   "is_sub_contracted_item": 0,
   "item_code": "_Test Item Home Desktop 100",
@@ -95,9 +89,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 0,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
-  "is_stock_item": 1,
   "is_sub_contracted_item": 0,
   "item_code": "_Test Item Home Desktop 200",
   "item_group": "_Test Item Group Desktops",
@@ -115,8 +106,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 0,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 0,
   "is_sub_contracted_item": 0,
   "item_code": "_Test Product Bundle Item",
@@ -136,8 +125,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 1,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 1,
   "is_sub_contracted_item": 1,
   "item_code": "_Test FG Item",
@@ -153,8 +140,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 0,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 0,
   "is_sub_contracted_item": 0,
   "item_code": "_Test Non Stock Item",
@@ -171,8 +156,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 0,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 1,
   "is_sub_contracted_item": 0,
   "item_code": "_Test Serialized Item",
@@ -189,8 +172,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 0,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 1,
   "is_sub_contracted_item": 0,
   "item_code": "_Test Serialized Item With Series",
@@ -211,7 +192,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 1,
-  "is_sales_item": 1,
   "is_stock_item": 1,
   "is_sub_contracted_item": 0,
   "item_code": "_Test Item Home Desktop Manufactured",
@@ -231,8 +211,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 1,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 1,
   "is_sub_contracted_item": 1,
   "item_code": "_Test FG Item 2",
@@ -252,8 +230,6 @@
   "inspection_required": 0,
   "is_fixed_asset": 0,
   "is_pro_applicable": 1,
-  "is_purchase_item": 1,
-  "is_sales_item": 1,
   "is_stock_item": 1,
   "is_sub_contracted_item": 1,
   "item_code": "_Test Variant Item",
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 0c0b582..2fe3bb7 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -27,9 +27,8 @@
 		return _("From {0} to {1}").format(self.from_warehouse, self.to_warehouse)
 
 	def onload(self):
-		if self.docstatus==1:
-			for item in self.get("items"):
-				item.update(get_bin_details(item.item_code, item.s_warehouse))
+		for item in self.get("items"):
+			item.update(get_bin_details(item.item_code, item.s_warehouse))
 
 	def validate(self):
 		self.pro_doc = None
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 9032c7f..d8c4382 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -125,19 +125,10 @@
 	from erpnext.stock.doctype.item.item import validate_end_of_life
 	validate_end_of_life(item.name, item.end_of_life, item.disabled)
 
-	if args.transaction_type=="selling":
-		# validate if sales item or service item
-		if item.is_sales_item != 1:
-			throw(_("Item {0} must be a Sales Item").format(item.name))
-
-		if cint(item.has_variants):
-			throw(_("Item {0} is a template, please select one of its variants").format(item.name))
-
+	if args.transaction_type=="selling" and cint(item.has_variants):
+		throw(_("Item {0} is a template, please select one of its variants").format(item.name))
+		
 	elif args.transaction_type=="buying" and args.doctype != "Material Request":
-		# validate if purchase item or subcontracted item
-		if item.is_purchase_item != 1:
-			throw(_("Item {0} must be a Purchase Item").format(item.name))
-
 		if args.get("is_subcontracted") == "Yes" and item.is_sub_contracted_item != 1:
 			throw(_("Item {0} must be a Sub-contracted Item").format(item.name))
 
diff --git a/erpnext/stock/reorder_item.py b/erpnext/stock/reorder_item.py
index c637a12..c87e336 100644
--- a/erpnext/stock/reorder_item.py
+++ b/erpnext/stock/reorder_item.py
@@ -23,7 +23,6 @@
 
 	items_to_consider = frappe.db.sql_list("""select name from `tabItem` item
 		where is_stock_item=1 and has_variants=0
-			and (is_purchase_item=1 or is_sub_contracted_item=1)
 			and disabled=0
 			and (end_of_life is null or end_of_life='0000-00-00' or end_of_life > %(today)s)
 			and (exists (select name from `tabItem Reorder` ir where ir.parent=item.name)
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..d2f42d4 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
@@ -5,13 +5,13 @@
  "doctype": "Report",
  "idx": 1,
  "is_standard": "Yes",
- "modified": "2014-06-03 07:18:17.128918",
+ "modified": "2014-06-03 07:18:17.128919",
  "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", 
+ "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 tabBin.projected_qty < 0\nORDER BY\n    tabBin.projected_qty ASC", 
  "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/maintenance_schedule/maintenance_schedule.js b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js
index 650429c..ab66046 100644
--- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js
+++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js
@@ -104,13 +104,6 @@
 	}
 }
 
-
-cur_frm.fields_dict['items'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
-	return {
-		filters:{ 'is_sales_item': 1 }
-	}
-}
-
 cur_frm.cscript.generate_schedule = function(doc, cdt, cdn) {
 	if (!doc.__islocal) {
 		return $c('runserverobj', args={'method':'generate_schedule', 'docs':doc},
diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js
index 65a84c0..b37c47b 100644
--- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js
+++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js
@@ -79,12 +79,6 @@
   	}
 }
 
-cur_frm.fields_dict['purposes'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
-	return{
-    	filters:{ 'is_sales_item': 1}
-  	}
-}
-
 cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) {
 	return {query: "erpnext.controllers.queries.customer_query" }
 }
\ No newline at end of file
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/erpnext/utilities/doctype/address/address.json b/erpnext/utilities/doctype/address/address.json
index d148368..558e0b7 100644
--- a/erpnext/utilities/doctype/address/address.json
+++ b/erpnext/utilities/doctype/address/address.json
@@ -644,7 +644,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-04-06 05:39:46.951866", 
+ "modified": "2016-04-15 03:09:31.497272", 
  "modified_by": "Administrator", 
  "module": "Utilities", 
  "name": "Address", 
@@ -731,6 +731,7 @@
    "write": 1
   }
  ], 
+ "quick_entry": 0, 
  "read_only": 0, 
  "read_only_onload": 0, 
  "search_fields": "customer, supplier, sales_partner, country, state", 
diff --git a/setup.py b/setup.py
index 581e065..4b31d06 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.9"
 requirements = parse_requirements("requirements.txt", session="")
 
 setup(
diff --git a/travis/bench_init.sh b/travis/bench_init.sh
new file mode 100755
index 0000000..a8bb492
--- /dev/null
+++ b/travis/bench_init.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+cd ~/
+curl -I https://github.com/frappe/frappe/tree/$TRAVIS_BRANCH | head -n 1 | cut -d $' ' -f2 | (
+	read response;
+	[ $response == '200' ] && branch=$TRAVIS_BRANCH || branch='develop';
+	bench init frappe-bench --frappe-path https://github.com/frappe/frappe.git --frappe-branch $branch
+)