Merge branch 'hotfix'
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..aa3a104
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,68 @@
+---
+name: Bug report
+about: Create a report to help us improve
+
+---
+
+Issue: Bug report
+
+Our project, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
+
+**Do the checklist before filing an issue:**
+ - [ ] Have a usage question? Ask your question on  [Discuss Forum](https://discuss.erpnext.com). We use [Discuss Forum](https://discuss.erpnext.com) for usage question and GitHub for bugs.
+ - [ ] Can you replicate the issue? 
+ - [ ] Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome
+
+**Describe the bug** :chart_with_downwards_trend: 
+A clear and concise description of what the bug is.
+
+**To Reproduce** :page_with_curl:
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior** :chart_with_upwards_trend:
+A clear and concise description of what you expected to happen.
+
+**Screenshots** :crystal_ball:
+If applicable, add screenshots to help explain your problem.
+
+**Desktop (please complete the following information):** :cyclone:
+ - OS:
+    - [ ] Linux
+    - [ ] macOS
+    - [ ] Windows
+    - [ ] Others? Please mention: 
+ - Browser:
+    - [ ] Safari
+    - [ ] Chrome
+    - [ ] Firefox
+    - [ ] Other? Please mention: 
+
+**Smartphone (please complete the following information):** :iphone: :computer:
+ - Device:
+    - [ ] iPhone
+    - [ ] Android
+ - Browser:
+    - [ ] Safari
+    - [ ] Chrome
+    - [ ] Firefox
+    - [ ] Other? Please mention: 
+
+**Version Information**
+- Which branch are you on?
+    - [ ] `master` :star2: 
+    - [ ] `develop` :fire:
+- Frappe Version: 
+- ERPNext Version: 
+
+**Additional context** :page_facing_up:
+Add any other context about the problem here.
+
+**Possible Solution** :bookmark_tabs:
+Any idea what might be causing the issue. Or if you have a proposed solution to the problem,
+
+**Please don't be intimidated by the long list of options you've fill. Try to fill out as much as you can. Remember, the more the information the easier it is for us to replicate and fix the issue** :grin: 
+
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..e09e5e9
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,21 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+
+---
+
+Issue: Feature Request
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
+
+
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..8e2bd85
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,28 @@
+Pull-Request
+
+- [ ] Have you followed the guidelines in our Contributing document?
+- [ ] Have you checked to ensure there aren't other open [Pull Requests](../pulls) for the same update/change?
+- [ ] Have you lint your code locally prior to submission?
+- [ ] Have you successfully run tests with your changes locally?
+- [ ] Does your commit message have an explanation for your changes and why you'd like us to include them?
+- [ ] Docs have been added / updated
+- [ ] Tests for the changes have been added (for bug fixes / features)
+- [ ] Did you modify the existing test cases? If yes, why?
+
+---
+
+What type of a PR is this? 
+
+- [ ] Changes to Existing Features
+- [ ] New Feature Submissions
+- [ ] Bug Fix
+- [ ] Breaking Change
+
+--- 
+
+- Motivation and Context (What existing problem does the pull request solve):
+- Related Issue: 
+- Screenshots (if applicable, remember, a picture tells a thousand words): 
+
+**Please don't be intimidated by the long list of options you've fill. Try to fill out as much as you can. Remember, the more the information the easier it is for us to test and get your pull request merged** :grin: 
+
diff --git a/.gitignore b/.gitignore
index 0d39ab2..dcdefa2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
 *.egg-info
 dist/
 erpnext/docs/current
+*.swp
diff --git a/.swp b/.swp
deleted file mode 100644
index 5a492bd..0000000
--- a/.swp
+++ /dev/null
Binary files differ
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index a88326d..6503508 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -5,7 +5,7 @@
 from erpnext.hooks import regional_overrides
 from frappe.utils import getdate
 
-__version__ = '10.1.35'
+__version__ = '10.1.36'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index f282afe..b940a6a 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -3410,6 +3410,65 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Group same items",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "column_break_112",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
    "fieldname": "select_print_heading", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -3914,7 +3973,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-12-20 17:49:51.230092", 
+ "modified": "2018-05-28 02:38:40.310899",
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Invoice", 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 5b52bbb..a033bb0 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -3742,12 +3742,12 @@
   },
   {
    "allow_bulk_edit": 0,
-   "allow_on_submit": 0,
+   "allow_on_submit": 1,
    "bold": 0,
    "collapsible": 0,
    "columns": 0,
-   "fieldname": "language",
-   "fieldtype": "Data",
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
    "hidden": 0,
    "ignore_user_permissions": 0,
    "ignore_xss_filter": 0,
@@ -3755,14 +3755,14 @@
    "in_global_search": 0,
    "in_list_view": 0,
    "in_standard_filter": 0,
-   "label": "Print Language",
+   "label": "Group same items",
    "length": 0,
    "no_copy": 0,
    "permlevel": 0,
    "precision": "",
    "print_hide": 1,
    "print_hide_if_no_value": 0,
-   "read_only": 1,
+   "read_only": 0,
    "remember_last_selected_value": 0,
    "report_hide": 0,
    "reqd": 0,
@@ -3835,6 +3835,36 @@
    "allow_bulk_edit": 0,
    "allow_on_submit": 0,
    "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "language",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Print Language",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 1,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
    "collapsible": 1,
    "columns": 0,
    "depends_on": "customer",
@@ -4683,7 +4713,7 @@
  "istable": 0,
  "max_attachments": 0,
  "menu_index": 0,
- "modified": "2018-03-16 15:19:54.711885",
+ "modified": "2018-05-28 04:47:29.879475",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Sales Invoice",
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 7fc0f67..a09c0a8 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -404,10 +404,21 @@
 	from frappe.desk.form.load import get_communication_data
 
 	out = {}
+	fields = 'date(creation), count(name)'
+	after = add_years(None, -1).strftime('%Y-%m-%d')
+	group_by='group by date(creation)'
+
 	data = get_communication_data(doctype, name,
-		fields = 'date(creation), count(name)',
-		after = add_years(None, -1).strftime('%Y-%m-%d'),
-		group_by='group by date(creation)', as_dict=False)
+		fields=fields, after=after, group_by=group_by, as_dict=False)
+
+	# fetch and append data from Activity Log
+	data += frappe.db.sql("""select {fields}
+		from `tabActivity Log`
+		where reference_doctype='{doctype}' and reference_name='{name}'
+		and status!='Success' and creation > {after}
+		{group_by} order by creation desc
+		""".format(doctype=doctype, name=name, fields=fields,
+			group_by=group_by, after=after), as_dict=False)
 
 	timeline_items = dict(data)
 
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 710099e..72661ff 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
@@ -49,7 +49,7 @@
 
 		row += [
 			d.credit_to, d.mode_of_payment, d.project, d.company, d.purchase_order,
-			purchase_receipt, expense_account, d.stock_qty, d.stock_uom, d.base_net_rate, d.base_net_amount
+			purchase_receipt, expense_account, d.stock_qty, d.stock_uom, d.base_net_amount / d.stock_qty, d.base_net_amount
 		]
 
 		total_tax = 0
@@ -120,8 +120,7 @@
 			`tabPurchase Invoice Item`.`project`, `tabPurchase Invoice Item`.`purchase_order`,
 			`tabPurchase Invoice Item`.`purchase_receipt`, `tabPurchase Invoice Item`.`po_detail`,
 			`tabPurchase Invoice Item`.`expense_account`, `tabPurchase Invoice Item`.`stock_qty`,
-			`tabPurchase Invoice Item`.`stock_uom`, `tabPurchase Invoice Item`.`base_net_rate`,
-			`tabPurchase Invoice Item`.`base_net_amount`,
+			`tabPurchase Invoice Item`.`stock_uom`, `tabPurchase Invoice Item`.`base_net_amount`,
 			`tabPurchase Invoice`.supplier_name, `tabPurchase Invoice`.mode_of_payment {0}
 		from `tabPurchase Invoice`, `tabPurchase Invoice Item`
 		where `tabPurchase Invoice`.name = `tabPurchase Invoice Item`.`parent` and
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
index b94710f..ad47d52 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
@@ -2177,6 +2177,65 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Group same items",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "column_break_72",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
    "fieldname": "letter_head", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -2490,7 +2549,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-11-29 14:07:56.698355", 
+ "modified": "2018-05-28 02:45:48.616334",
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Supplier Quotation", 
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 4cca720..58073bc 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -82,7 +82,8 @@
 			self.validate_non_invoice_documents_schedule()
 
 	def before_print(self):
-		if self.doctype in ['Purchase Order', 'Sales Order']:
+		if self.doctype in ['Purchase Order', 'Sales Order', 'Sales Invoice', 'Purchase Invoice',
+			'Supplier Quotation', 'Purchase Receipt', 'Delivery Note', 'Quotation']:
 			if self.get("group_same_items"):
 				self.group_similar_items()
 
@@ -663,6 +664,7 @@
 			if item.item_code in group_item_qty:
 				item.qty = group_item_qty[item.item_code]
 				item.amount = group_item_amount[item.item_code]
+				item.rate = flt(flt(item.amount)/flt(item.qty), item.precision("rate"))
 				del group_item_qty[item.item_code]
 			else:
 				duplicate_list.append(item)
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index a4d9dae..b44f597 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -38,6 +38,7 @@
 		self.manipulate_grand_total_for_inclusive_tax()
 		self.calculate_totals()
 		self._cleanup()
+		self.calculate_total_net_weight()
 
 	def validate_conversion_rate(self):
 		# validate conversion rate
@@ -328,6 +329,13 @@
 
 		self.set_rounded_total()
 
+	def calculate_total_net_weight(self):
+		if self.doc.meta.get_field('total_net_weight'):
+			self.doc.total_net_weight = 0.0
+			for d in self.doc.items:
+				if d.total_weight:
+					self.doc.total_net_weight += d.total_weight
+
 	def set_rounded_total(self):
 		if self.doc.meta.get_field("rounded_total"):
 			if self.doc.is_rounded_total_disabled():
diff --git a/erpnext/healthcare/doctype/consultation/consultation.py b/erpnext/healthcare/doctype/consultation/consultation.py
index ebf80d6..30b3734 100755
--- a/erpnext/healthcare/doctype/consultation/consultation.py
+++ b/erpnext/healthcare/doctype/consultation/consultation.py
@@ -6,7 +6,7 @@
 import frappe
 from frappe import _
 from frappe.model.document import Document
-from frappe.utils import getdate
+from frappe.utils import getdate, cstr
 import json
 from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account
 
@@ -125,7 +125,7 @@
 def set_subject_field(consultation):
 	subject = "No Diagnosis "
 	if(consultation.diagnosis):
-		subject = "Diagnosis: \n"+ str(consultation.diagnosis)+". "
+		subject = "Diagnosis: \n"+ cstr(consultation.diagnosis)+". "
 	if(consultation.drug_prescription):
 		subject +="\nDrug(s) Prescribed. "
 	if(consultation.test_prescription):
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py
index 3ad8b53..b3b64f4 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.py
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.py
@@ -6,7 +6,7 @@
 import frappe
 from frappe.model.document import Document
 import json
-from frappe.utils import getdate
+from frappe.utils import getdate, cstr
 from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account
 from frappe import _
 
@@ -228,9 +228,9 @@
 	return employee
 
 def insert_lab_test_to_medical_record(doc):
-	subject = str(doc.test_name)
+	subject = cstr(doc.test_name)
 	if(doc.test_comment):
-		subject += ", \n"+str(doc.test_comment)
+		subject += ", \n"+ cstr(doc.test_comment)
 	medical_record = frappe.new_doc("Patient Medical Record")
 	medical_record.patient = doc.patient
 	medical_record.subject = subject
diff --git a/erpnext/healthcare/doctype/vital_signs/vital_signs.py b/erpnext/healthcare/doctype/vital_signs/vital_signs.py
index dea848d..9aa055c 100644
--- a/erpnext/healthcare/doctype/vital_signs/vital_signs.py
+++ b/erpnext/healthcare/doctype/vital_signs/vital_signs.py
@@ -5,6 +5,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.model.document import Document
+from frappe.utils import cstr
 
 class VitalSigns(Document):
 	def on_submit(self):
@@ -33,16 +34,16 @@
 def set_subject_field(doc):
 	subject = " "
 	if(doc.temperature):
-		subject += "Temperature: \n"+ str(doc.temperature)+". "
+		subject += "Temperature: \n"+ cstr(doc.temperature)+". "
 	if(doc.pulse):
-		subject += "Pulse: \n"+ str(doc.pulse)+". "
+		subject += "Pulse: \n"+ cstr(doc.pulse)+". "
 	if(doc.respiratory_rate):
-		subject += "Respiratory Rate: \n"+ str(doc.respiratory_rate)+". "
+		subject += "Respiratory Rate: \n"+ cstr(doc.respiratory_rate)+". "
 	if(doc.bp):
-		subject += "BP: \n"+ str(doc.bp)+". "
+		subject += "BP: \n"+ cstr(doc.bp)+". "
 	if(doc.bmi):
-		subject += "BMI: \n"+ str(doc.bmi)+". "
+		subject += "BMI: \n"+ cstr(doc.bmi)+". "
 	if(doc.nutrition_note):
-		subject += "Note: \n"+ str(doc.nutrition_note)+". "
+		subject += "Note: \n"+ cstr(doc.nutrition_note)+". "
 
 	return subject
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 2eb0804..ade6217 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -502,3 +502,4 @@
 erpnext.patches.v10_0.taxes_issue_with_pos
 erpnext.patches.v10_0.set_qty_in_transactions_based_on_serial_no_input
 erpnext.patches.v10_0.show_leaves_of_all_department_members_in_calendar
+erpnext.patches.v10_0.update_status_in_purchase_receipt
diff --git a/erpnext/patches/v10_0/update_status_in_purchase_receipt.py b/erpnext/patches/v10_0/update_status_in_purchase_receipt.py
new file mode 100644
index 0000000..69e2bb8
--- /dev/null
+++ b/erpnext/patches/v10_0/update_status_in_purchase_receipt.py
@@ -0,0 +1,7 @@
+import frappe
+
+def execute():
+	frappe.reload_doc("stock", "doctype", "purchase_receipt")
+	frappe.db.sql('''
+		UPDATE `tabPurchase Receipt` SET status = "Completed" WHERE per_billed = 100 AND docstatus = 1
+	''')
\ No newline at end of file
diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json
index 1c40ec3..61973d6 100644
--- a/erpnext/selling/doctype/quotation/quotation.json
+++ b/erpnext/selling/doctype/quotation/quotation.json
@@ -2439,8 +2439,8 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "select_print_heading", 
-   "fieldtype": "Link", 
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
@@ -2448,18 +2448,16 @@
    "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
-   "label": "Print Heading", 
+   "label": "Group same items",
    "length": 0, 
-   "no_copy": 1, 
-   "oldfieldname": "select_print_heading", 
-   "oldfieldtype": "Link", 
-   "options": "Print Heading", 
+   "no_copy": 0,
    "permlevel": 0, 
+   "precision": "",
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "remember_last_selected_value": 0, 
-   "report_hide": 1, 
+   "report_hide": 0,
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
@@ -2496,6 +2494,38 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "select_print_heading",
+   "fieldtype": "Link",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Print Heading",
+   "length": 0,
+   "no_copy": 1,
+   "oldfieldname": "select_print_heading",
+   "oldfieldtype": "Link",
+   "options": "Print Heading",
+   "permlevel": 0,
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 1,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -2881,8 +2911,8 @@
  "istable": 0, 
  "max_attachments": 1, 
  "menu_index": 0, 
- "modified": "2017-12-19 14:52:28.966139", 
- "modified_by": "nabinhait@gmail.com", 
+ "modified": "2018-05-28 03:23:15.354674",
+ "modified_by": "Administrator",
  "module": "Selling", 
  "name": "Quotation", 
  "owner": "Administrator", 
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
index e7bb5b4..fd5bc4e 100644
--- a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
+++ b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
@@ -98,7 +98,7 @@
 		END as qty,
 		CASE
 			WHEN so.status = "Closed" THEN sum(soi.delivered_qty * soi.conversion_factor * soi.base_net_rate * (st.allocated_percentage/100))
-			ELSE soi.base_net_amount * (st.allocated_percentage/100))
+			ELSE sum(soi.base_net_amount * (st.allocated_percentage/100))
 		END as amount
 		from
 			`tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json
index 9c1373b..e377783 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.json
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.json
@@ -3157,6 +3157,36 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Group same items",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 1, 
@@ -3701,7 +3731,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2018-03-13 15:35:02.234116", 
+ "modified": "2018-05-28 03:03:35.035396",
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Delivery Note", 
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index 909fa2c..70a0612 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -82,6 +82,8 @@
 			for f in fieldname:
 				toggle_print_hide(self.meta if key == "parent" else item_meta, f)
 
+		super(DeliveryNote, self).before_print()
+
 	def set_actual_qty(self):
 		for d in self.get('items'):
 			if d.item_code and d.warehouse:
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index 74dfa05..0c55b43 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -49,7 +49,8 @@
 	pi.qty = flt(qty)
 	pi.description = description
 	if not pi.warehouse:
-		pi.warehouse = item.default_warehouse or main_item_row.warehouse
+		pi.warehouse = (main_item_row.warehouse
+			if (doc.get('is_pos') or not item.default_warehouse) else item.default_warehouse)
 	if not pi.batch_no:
 		pi.batch_no = cstr(main_item_row.get("batch_no"))
 	if not pi.target_warehouse:
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
index 8c86c8b..3f4337f 100755
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
@@ -2978,10 +2978,69 @@
   }, 
   {
    "allow_bulk_edit": 0, 
+   "allow_on_submit": 1,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
+   "fieldname": "group_same_items",
+   "fieldtype": "Check",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "label": "Group same items",
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 1,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "column_break_97",
+   "fieldtype": "Column Break",
+   "hidden": 0,
+   "ignore_user_permissions": 0,
+   "ignore_xss_filter": 0,
+   "in_filter": 0,
+   "in_global_search": 0,
+   "in_list_view": 0,
+   "in_standard_filter": 0,
+   "length": 0,
+   "no_copy": 0,
+   "permlevel": 0,
+   "precision": "",
+   "print_hide": 0,
+   "print_hide_if_no_value": 0,
+   "read_only": 0,
+   "remember_last_selected_value": 0,
+   "report_hide": 0,
+   "reqd": 0,
+   "search_index": 0,
+   "set_only_once": 0,
+   "unique": 0
+  },
+  {
+   "allow_bulk_edit": 0,
+   "allow_on_submit": 0,
+   "bold": 0,
+   "collapsible": 0,
+   "columns": 0,
    "fieldname": "other_details", 
    "fieldtype": "HTML", 
    "hidden": 1, 
@@ -3242,7 +3301,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-11-29 14:15:10.309900", 
+ "modified": "2018-05-28 02:59:59.609643",
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Purchase Receipt", 
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 2a962cc..80dc4e1 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -120,6 +120,8 @@
 		self.update_prevdoc_status()
 		if self.per_billed < 100:
 			self.update_billing_status()
+		else:
+			self.status = "Completed"
 
 		# Updating stock ledger should always be called after updating prevdoc status,
 		# because updating ordered qty, reserved_qty_for_subcontract in bin
diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py
index 1a91ab4..ec95561 100644
--- a/erpnext/stock/report/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.py
@@ -56,7 +56,7 @@
 	item_conditions_sql = ''
 	if items:
 		item_conditions_sql = 'and sle.item_code in ({})'\
-			.format(', '.join(['"' + frappe.db.escape(i,percent=False) + '"' for i in items]))
+			.format(', '.join(['"' + frappe.db.escape(i) + '"' for i in items]))
 
 	return frappe.db.sql("""select concat_ws(" ", posting_date, posting_time) as date,
 			item_code, warehouse, actual_qty, qty_after_transaction, incoming_rate, valuation_rate,
diff --git a/erpnext/utilities/page/leaderboard/leaderboard.js b/erpnext/utilities/page/leaderboard/leaderboard.js
index 1c085f2..c5f2e87 100644
--- a/erpnext/utilities/page/leaderboard/leaderboard.js
+++ b/erpnext/utilities/page/leaderboard/leaderboard.js
@@ -85,7 +85,7 @@
 
 		this.$sidebar_list.on('click', 'li', function(e) {
 			let $li = $(this);
-			let doctype = $li.find('span').html();
+			let doctype = $li.find('span').attr("doctype-value");
 
 			me.options.selected_company = frappe.defaults.get_default('company');
 			me.options.selected_doctype = doctype;
@@ -172,7 +172,7 @@
 			$container.find(".leaderboard-list").html(me.render_list_view(res.message));
 		} else {
 			me.$graph_area.hide();
-			me.message = "No items found.";
+			me.message = __("No items found.");
 			$container.find(".leaderboard-list").html(me.render_list_view());
 		}
 	},
@@ -301,7 +301,7 @@
 	get_sidebar_item: function(item) {
 		return $(`<li class="strong module-sidebar-item">
 			<a class="module-link">
-			<span>${ item }</span></a>
+			<span doctype-value="${item}">${ __(item) }</span></a>
 		</li>`);
 	}
 });