Merge pull request #9558 from mbauskar/domainify-school

[domainify] Domainification for the Education Domain
diff --git a/.eslintrc b/.eslintrc
index 452f3ec..c9cd552 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -131,6 +131,7 @@
 		"getCookies": true,
 		"get_url_arg": true,
 		"get_server_fields": true,
-		"set_multiple": true
+		"set_multiple": true,
+		"QUnit": true
 	}
 }
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..4a97d8b
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,46 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hello@frappe.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 71323d1..95c5f8a 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '8.2.2'
+__version__ = '8.2.3'
 
 
 def get_default_company(user=None):
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
index 49af59b..777b34b 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
  "allow_import": 1, 
  "allow_rename": 1, 
  "autoname": "field:title", 
@@ -12,6 +13,7 @@
  "editable_grid": 0, 
  "fields": [
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -40,6 +42,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -69,6 +72,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -99,6 +103,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -129,6 +134,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -159,6 +165,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -189,6 +196,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -217,6 +225,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -247,6 +256,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -275,6 +285,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -303,6 +314,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -331,6 +343,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -359,6 +372,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -387,6 +401,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -417,6 +432,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -447,6 +463,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -477,6 +494,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -507,6 +525,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -537,6 +556,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -567,6 +587,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -597,6 +618,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -627,6 +649,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -655,6 +678,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -683,6 +707,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -711,6 +736,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -739,6 +765,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -767,6 +794,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -796,6 +824,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -824,6 +853,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -851,6 +881,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -880,6 +911,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -910,6 +942,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -941,6 +974,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -969,6 +1003,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1000,6 +1035,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1028,6 +1064,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1058,6 +1095,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1085,6 +1123,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1114,6 +1153,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1143,6 +1183,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1173,6 +1214,39 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "depends_on": "eval:doc.price_or_discount==\"Price\"", 
+   "fieldname": "currency", 
+   "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": "Currency", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Currency", 
+   "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, 
@@ -1202,6 +1276,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1230,18 +1305,18 @@
    "unique": 0
   }
  ], 
+ "has_web_view": 0, 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "icon": "fa fa-gift", 
  "idx": 1, 
  "image_view": 0, 
  "in_create": 0, 
- "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-02-17 16:21:28.446208", 
+ "modified": "2017-06-26 19:35:50.651619", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Pricing Rule", 
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index 71897d4..af31d9b 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -23,6 +23,7 @@
 		self.validate_price_or_discount()
 		self.validate_max_discount()
 
+		if self.price_or_discount != 'Price': self.currency = None
 		if not self.margin_type: self.margin_rate_or_amount = 0.0
 
 	def validate_mandatory(self):
@@ -179,9 +180,15 @@
 		item_details.margin_type = pricing_rule.margin_type
 		item_details.margin_rate_or_amount = pricing_rule.margin_rate_or_amount
 		if pricing_rule.price_or_discount == "Price":
+			if pricing_rule.get('currency') and \
+				pricing_rule.currency == args.currency:
+				price_list_rate = pricing_rule.price * (args.conversion_factor or 1.0)
+			else:
+				price_list_rate = (pricing_rule.price/flt(args.conversion_rate)) * args.conversion_factor or 1.0 \
+						if args.conversion_rate else 0.0
+
 			item_details.update({
-				"price_list_rate": (pricing_rule.price/flt(args.conversion_rate)) * args.conversion_factor or 1.0 \
-					if args.conversion_rate else 0.0,
+				"price_list_rate": price_list_rate,
 				"discount_percentage": 0.0
 			})
 		else:
@@ -240,7 +247,7 @@
 	conditions = item_variant_condition = ""
 	values =  {"item_code": args.get("item_code"), "brand": args.get("brand")}
 
-	for field in ["company", "customer", "supplier", "supplier_type", "campaign", "sales_partner"]:
+	for field in ["company", "customer", "supplier", "supplier_type", "campaign", "sales_partner", "currency"]:
 		if args.get(field):
 			conditions += " and ifnull("+field+", '') in (%("+field+")s, '')"
 			values[field] = args.get(field)
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 36db684..8015fb7 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -3238,7 +3238,7 @@
    "in_filter": 0, 
    "in_global_search": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
+   "in_standard_filter": 1, 
    "label": "Status", 
    "length": 0, 
    "no_copy": 0, 
@@ -3767,10 +3767,11 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-06-13 14:28:57.930167", 
+ "modified": "2017-06-29 10:48:09.707735", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Invoice", 
+ "name_case": "Title Case", 
  "owner": "Administrator", 
  "permissions": [
   {
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 4a1685b..49665bb 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -71,17 +71,19 @@
 					});
 
 				if(!from_delivery_note && !is_delivered_by_supplier) {
-					cur_frm.add_custom_button(__('Delivery'), cur_frm.cscript['Make Delivery Note'],
-						__("Make"));
+					cur_frm.add_custom_button(__('Delivery'),
+						cur_frm.cscript['Make Delivery Note'], __("Make"));
 				}
 			}
 
 			if(doc.outstanding_amount!=0 && !cint(doc.is_return)) {
-				cur_frm.add_custom_button(__('Payment'), this.make_payment_entry, __("Make"));
+				cur_frm.add_custom_button(__('Payment'),
+					this.make_payment_entry, __("Make"));
 			}
 
 			if(doc.outstanding_amount>0 && !cint(doc.is_return)) {
-				cur_frm.add_custom_button(__('Payment Request'), this.make_payment_request, __("Make"));
+				cur_frm.add_custom_button(__('Payment Request'),
+					this.make_payment_request, __("Make"));
 			}
 
 
@@ -481,7 +483,7 @@
 			'Delivery Note': 'Delivery',
 			'Sales Invoice': 'Sales Return',
 			'Payment Request': 'Payment Request',
-			'Payment': 'Payment Entry'
+			'Payment Entry': 'Payment'
 		},
 		frm.fields_dict["timesheets"].grid.get_field("time_sheet").get_query = function(doc, cdt, cdn){
 			return{
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 36a66c6..a2e9ddf 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -2511,7 +2511,7 @@
    "in_filter": 0, 
    "in_global_search": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 1, 
+   "in_standard_filter": 0, 
    "label": "Outstanding Amount", 
    "length": 0, 
    "no_copy": 1, 
@@ -3597,7 +3597,7 @@
    "in_filter": 0, 
    "in_global_search": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
+   "in_standard_filter": 1, 
    "label": "Status", 
    "length": 0, 
    "no_copy": 1, 
@@ -4627,10 +4627,11 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-06-22 14:45:35.257640", 
+ "modified": "2017-06-29 10:47:49.522969", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Sales Invoice", 
+ "name_case": "Title Case", 
  "owner": "Administrator", 
  "permissions": [
   {
diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py
index bb5a82d..20939bd 100644
--- a/erpnext/accounts/report/gross_profit/gross_profit.py
+++ b/erpnext/accounts/report/gross_profit/gross_profit.py
@@ -278,7 +278,7 @@
 				inner join `tabSales Invoice Item` on `tabSales Invoice Item`.parent = `tabSales Invoice`.name
 				{sales_team_table}
 			where
-				`tabSales Invoice`.docstatus = 1 and `tabSales Invoice`.is_return != 1 {conditions} {match_cond}
+				`tabSales Invoice`.docstatus = 1 {conditions} {match_cond}
 			order by
 				`tabSales Invoice`.posting_date desc, `tabSales Invoice`.posting_time desc"""
 			.format(conditions=conditions, sales_person_cols=sales_person_cols,
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 19f74a6..7d10b19 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
@@ -24,7 +24,7 @@
 		"fieldtype": "Data",
 		"width": 80
 	})
-	company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
+	company_currency = frappe.db.get_value("Company", filters.get("company"), "default_currency")
 	mode_of_payments = get_mode_of_payments(set([d.parent for d in item_list]))
 
 	data = []
diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py
index 49f6471..c471b8b 100644
--- a/erpnext/accounts/report/sales_register/sales_register.py
+++ b/erpnext/accounts/report/sales_register/sales_register.py
@@ -26,7 +26,7 @@
 	invoice_so_dn_map = get_invoice_so_dn_map(invoice_list)
 	customers = list(set([inv.customer for inv in invoice_list]))
 	customer_map = get_customer_details(customers)
-	company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
+	company_currency = frappe.db.get_value("Company", filters.get("company"), "default_currency")
 	mode_of_payments = get_mode_of_payments([inv.name for inv in invoice_list])
 
 	data = []
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 0fc08c1..8130af9 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -68,14 +68,17 @@
 		fields = ["name", "customer_name", "customer_group", "territory"]
 
 	meta = frappe.get_meta("Customer")
-	fields = fields + [f for f in meta.get_search_fields() if not f in fields]
+	searchfields = meta.get_search_fields()
+	searchfields = searchfields + [f for f in [searchfield or "name", "customer_name"] \
+			if not f in searchfields]
+	fields = fields + [f for f in searchfields if not f in fields]
 
 	fields = ", ".join(fields)
+	searchfields = " or ".join([field + " like %(txt)s" for field in searchfields])
 
 	return frappe.db.sql("""select {fields} from `tabCustomer`
 		where docstatus < 2
-			and ({key} like %(txt)s
-				or customer_name like %(txt)s) and disabled=0
+			and ({scond}) and disabled=0
 			{mcond}
 		order by
 			if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
@@ -84,7 +87,7 @@
 			name, customer_name
 		limit %(start)s, %(page_len)s""".format(**{
 			"fields": fields,
-			"key": searchfield,
+			"scond": searchfields,
 			"mcond": get_match_cond(doctype)
 		}), {
 			'txt': "%%%s%%" % txt,
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 130554f..111bf88 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -409,3 +409,4 @@
 erpnext.patches.v8_0.save_system_settings
 erpnext.patches.v8_1.delete_deprecated_reports
 erpnext.patches.v8_1.setup_gst_india #2017-06-27
+execute:frappe.reload_doc('regional', 'doctype', 'gst_hsn_code')
diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js
index 644f0f5..aefc212 100644
--- a/erpnext/public/js/controllers/accounts.js
+++ b/erpnext/public/js/controllers/accounts.js
@@ -215,7 +215,7 @@
 			erpnext.taxes.set_conditional_mandatory_rate_or_amount(open_form);
 		} else {
 			// apply in current row
-			erpnext.taxes.set_conditional_mandatory_rate_or_amount(frm.get_field('taxes').grid.get_grid_row(cdn));
+			erpnext.taxes.set_conditional_mandatory_rate_or_amount(frm.get_field('taxes').grid.get_row(cdn));
 		}
 	});
 
diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json
index 989dfbc..1b77418 100644
--- a/erpnext/selling/doctype/customer/customer.json
+++ b/erpnext/selling/doctype/customer/customer.json
@@ -107,6 +107,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
@@ -168,10 +169,12 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "default": "Company", 
    "fieldname": "customer_type", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -186,7 +189,7 @@
    "no_copy": 0, 
    "oldfieldname": "customer_type", 
    "oldfieldtype": "Select", 
-   "options": "\nCompany\nIndividual", 
+   "options": "Company\nIndividual", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -1197,7 +1200,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-06-13 14:29:11.114613", 
+ "modified": "2017-06-28 14:55:39.910819", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Customer", 
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index 46e4d5c..71734f2 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -41,8 +41,7 @@
 			"email"				:"test@erpnext.com",
 			"password"			:"test",
 			"chart_of_accounts" : "Standard",
-			"domain"			: "Manufacturing",
-
+			"domain"			: "Manufacturing"
 		})
 
 	frappe.db.sql("delete from `tabLeave Allocation`")
diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py
index 80a7834..ceeceaa 100644
--- a/erpnext/startup/boot.py
+++ b/erpnext/startup/boot.py
@@ -4,10 +4,10 @@
 
 from __future__ import unicode_literals
 import frappe
+from frappe.utils.nestedset import get_root_of
 
 def boot_session(bootinfo):
 	"""boot session - send website info if guest"""
-	import frappe
 
 	bootinfo.custom_css = frappe.db.get_value('Style Settings', None, 'custom_css') or ''
 	bootinfo.website_settings = frappe.get_doc('Website Settings')
@@ -16,6 +16,8 @@
 		update_page_info(bootinfo)
 
 		load_country_and_currency(bootinfo)
+		bootinfo.sysdefaults.territory = get_root_of('Territory')
+		bootinfo.sysdefaults.customer_group = get_root_of('Customer Group')
 
 		bootinfo.notification_settings = frappe.get_doc("Notification Control",
 			"Notification Control")
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index f5f3493..9328194 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -524,7 +524,7 @@
 
 	def before_rename(self, old_name, new_name, merge=False):
 		if self.item_name==old_name:
-			self.item_name=new_name
+			frappe.db.set_value("Item", old_name, "item_name", new_name)
 
 		if merge:
 			# Validate properties before merging
diff --git a/erpnext/tests/sel_tests.py b/erpnext/tests/sel_tests.py
deleted file mode 100644
index 174e9c2..0000000
--- a/erpnext/tests/sel_tests.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-"""
-Run Selenium Tests
-
-Requires a clean install. After reinstalling fresh db, call
-
-	frappe --execute erpnext.tests.sel_tests.start
-
-"""
-
-from __future__ import unicode_literals
-import frappe
-
-from frappe.utils import sel
-import time
-
-def start():
-	try:
-		run()
-	finally:
-		sel.close()
-
-def run():
-	def next_slide(idx, selector="next-btn"):
-		sel.find('[data-slide-id="{0}"] .{1}'.format(idx, selector))[0].click()
-		sel.wait_for_ajax()
-
-
-	sel.start(verbose=True, driver="Firefox")
-	sel.input_wait = 0.2
-	sel.login("#page-setup-wizard")
-
-	# slide 1
-	next_slide("0")
-
-	sel.set_field("first_name", "Test")
-	sel.set_field("last_name", "User")
-	sel.set_field("email", "test@erpnext.com")
-	sel.set_field("password", "test")
-
-	next_slide("1")
-
-	sel.set_select("country", "India")
-
-	next_slide("2")
-
-	sel.set_field("company_name", "Wind Power LLC")
-	sel.set_field("fy_start_date", "01-04-2014")
-	sel.set_field("company_tagline", "Wind Power For Everyone")
-
-	next_slide("3")
-	next_slide("4")
-
-	sel.set_field("tax_1", "VAT")
-	sel.set_field("tax_rate_1", "12.5")
-
-	sel.set_field("tax_2", "Service Tax")
-	sel.set_field("tax_rate_2", "10.36")
-
-	next_slide("5")
-
-	sel.set_field("customer_1", "Asian Junction")
-	sel.set_field("customer_contact_1", "January Vaclavik")
-	sel.set_field("customer_2", "Life Plan Counselling")
-	sel.set_field("customer_contact_2", "Jana Tobeolisa")
-	sel.set_field("customer_3", "Two Pesos")
-	sel.set_field("customer_contact_3", "Satomi Shigeki")
-	sel.set_field("customer_4", "Intelacard")
-	sel.set_field("customer_contact_4", "Hans Rasmussen")
-
-	next_slide("6")
-
-	sel.set_field("item_1", "Wind Turbine A")
-	sel.set_field("item_2", "Wind Turbine B")
-	sel.set_field("item_3", "Wind Turbine C")
-
-	next_slide("7")
-
-	sel.set_field("supplier_1", "Helios Air")
-	sel.set_field("supplier_contact_1", "Quimey Osorio")
-	sel.set_field("supplier_2", "Ks Merchandise")
-	sel.set_field("supplier_contact_2", "Edgarda Salcedo")
-	sel.set_field("supplier_3", "Eagle Hardware")
-	sel.set_field("supplier_contact_3", "Hafsteinn Bjarnarsonar")
-
-	next_slide("8")
-
-	sel.set_field("item_buy_1", "Bearing Pipe")
-	sel.set_field("item_buy_2", "Bearing Assembly")
-	sel.set_field("item_buy_3", "Base Plate")
-	sel.set_field("item_buy_4", "Coil")
-
-	next_slide("9", "complete-btn")
-
-	sel.wait('[data-state="setup-complete"]')
-
-	w = raw_input("quit?")
-
-# complete setup
-# new customer
-# new supplier
-# new item
-# sales cycle
-# purchase cycle
diff --git a/erpnext/tests/test_client.py b/erpnext/tests/test_client.py
deleted file mode 100644
index bf88341..0000000
--- a/erpnext/tests/test_client.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-from __future__ import unicode_literals
-
-import unittest, frappe
-from frappe.utils import sel
-from frappe.utils import formatdate
-
-#selenium_tests = True
-
-# class TestLogin(unittest.TestCase):
-# 	def setUp(self):
-# 		sel.login()
-#
-# 	def test_material_request(self):
-# 		sel.new_doc("Stock", "Material Request")
-# 		sel.set_field("company", "_Test Company")
-# 		sel.add_child("items")
-# 		sel.set_field("item_code", "_Test Item")
-# 		sel.set_field("qty", "1")
-# 		sel.set_field("warehouse", "_Test Warehouse - _TC")
-# 		sel.set_field("schedule_date", formatdate())
-# 		sel.done_add_child("items")
-# 		sel.primary_action()
-# 		sel.wait_for_state("clean")
diff --git a/erpnext/tests/test_init.py b/erpnext/tests/test_init.py
index 2baea97..43340ce 100644
--- a/erpnext/tests/test_init.py
+++ b/erpnext/tests/test_init.py
@@ -6,7 +6,6 @@
 
 test_records = frappe.get_test_records('Company')
 
-
 class TestInit(unittest.TestCase):
 	def test_encode_company_abbr(self):
 		company = frappe.new_doc("Company")
diff --git a/erpnext/tests/ui/test_fixtures.js b/erpnext/tests/ui/test_fixtures.js
new file mode 100644
index 0000000..e4ee664
--- /dev/null
+++ b/erpnext/tests/ui/test_fixtures.js
@@ -0,0 +1,48 @@
+$.extend(frappe.test_data, {
+	'Customer': {
+		'Test Customer 1': [
+			{customer_name: 'Test Customer 1'}
+		],
+		'Test Customer 2': [
+			{customer_name: 'Test Customer 2'}
+		],
+		'Test Customer 3': [
+			{customer_name: 'Test Customer 3'}
+		],
+	},
+	'Item': {
+		'Test Product 1': [
+			{item_code: 'Test Product 1'},
+			{item_group: 'Products'},
+			{is_stock_item: 1},
+			{standard_rate: 100},
+			{opening_stock: 100},
+		],
+		'Test Product 2': [
+			{item_code: 'Test Product 2'},
+			{item_group: 'Products'},
+			{is_stock_item: 1},
+			{standard_rate: 150},
+			{opening_stock: 200},
+		],
+		'Test Product 3': [
+			{item_code: 'Test Product 3'},
+			{item_group: 'Products'},
+			{is_stock_item: 1},
+			{standard_rate: 250},
+			{opening_stock: 100},
+		],
+		'Test Service 1': [
+			{item_code: 'Test Service 1'},
+			{item_group: 'Services'},
+			{is_stock_item: 0},
+			{standard_rate: 200}
+		],
+		'Test Service 2': [
+			{item_code: 'Test Service 2'},
+			{item_group: 'Services'},
+			{is_stock_item: 0},
+			{standard_rate: 300}
+		]
+	}
+});
\ No newline at end of file
diff --git a/erpnext/tests/ui/test_sellling.js b/erpnext/tests/ui/test_sellling.js
new file mode 100644
index 0000000..5543a67
--- /dev/null
+++ b/erpnext/tests/ui/test_sellling.js
@@ -0,0 +1,29 @@
+QUnit.module('sales');
+
+QUnit.test("test quotation", function(assert) {
+	assert.expect(2);
+	let done = assert.async();
+	frappe.run_serially([
+		() => frappe.tests.setup_doctype('Customer'),
+		() => frappe.tests.setup_doctype('Item'),
+		() => {
+			return frappe.tests.make('Quotation', [
+				{customer: 'Test Customer 1'},
+				{items: [
+					[
+						{'item_code': 'Test Product 1'},
+						{'qty': 5}
+					]
+				]}
+			]);
+		},
+		() => {
+			// get_item_details
+			assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1');
+
+			// calculate_taxes_and_totals
+			assert.ok(cur_frm.doc.grand_total==500);
+		},
+		() => done()
+	]);
+});