fixed merge-conflicts
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index b16e299..07db5e8 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -4,7 +4,7 @@
 import frappe
 from erpnext.hooks import regional_overrides
 
-__version__ = '9.2.16'
+__version__ = '9.2.17'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py
index 6b7d99f..65b0e7c 100644
--- a/erpnext/accounts/doctype/pos_profile/pos_profile.py
+++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py
@@ -19,7 +19,7 @@
 
 	def check_for_duplicate(self):
 		res = frappe.db.sql("""select name, user from `tabPOS Profile`
-			where ifnull(user, '') = %s and name != %s and company = %s""",
+			where ifnull(user, '') = %s and name != %s and company = %s and ifnull(disabled, 0) != 1""",
 			(self.user, self.name, self.company))
 		if res:
 			if res[0][1]:
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index e767ae7..fac70aa 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -51,6 +51,7 @@
 		self.validate_with_previous_doc()
 		self.validate_for_subcontracting()
 		self.validate_minimum_order_qty()
+		self.validate_bom_for_subcontracting_items()
 		self.create_raw_materials_supplied("supplied_items")
 		self.set_received_qty_for_drop_ship_items()
 
@@ -95,6 +96,13 @@
 				frappe.throw(_("Item {0}: Ordered qty {1} cannot be less than minimum order qty {2} (defined in Item).").format(item_code,
 					qty, itemwise_min_order_qty.get(item_code)))
 
+	def validate_bom_for_subcontracting_items(self):
+		if self.is_subcontracted == "Yes":
+			for item in self.items:
+				if not item.bom:
+					frappe.throw(_("BOM is not specified for subcontracting item {0} at row {1}"\
+						.format(item.item_code, item.idx)))
+
 	def get_schedule_dates(self):
 		for d in self.get('items'):
 			if d.material_request_item and not d.schedule_date:
diff --git a/erpnext/crm/doctype/opportunity/opportunity_dashboard.py b/erpnext/crm/doctype/opportunity/opportunity_dashboard.py
index 1939c2e..bd4a6a2 100644
--- a/erpnext/crm/doctype/opportunity/opportunity_dashboard.py
+++ b/erpnext/crm/doctype/opportunity/opportunity_dashboard.py
@@ -5,6 +5,7 @@
 		'fieldname': 'prevdoc_docname',
 		'non_standard_fieldnames': {
 			'Supplier Quotation': 'opportunity',
+			'Quotation': 'opportunity'
 		},
 		'transactions': [
 			{
diff --git a/erpnext/healthcare/doctype/consultation/consultation.js b/erpnext/healthcare/doctype/consultation/consultation.js
index 15a1c7f..8ed01c3 100644
--- a/erpnext/healthcare/doctype/consultation/consultation.js
+++ b/erpnext/healthcare/doctype/consultation/consultation.js
@@ -139,6 +139,7 @@
 	}
 	frappe.route_options = {
 		"patient": frm.doc.patient,
+		"appointment": frm.doc.appointment
 	};
 	frappe.new_doc("Vital Signs");
 };
diff --git a/erpnext/healthcare/doctype/consultation/consultation.json b/erpnext/healthcare/doctype/consultation/consultation.json
index 400703a..1eff21d 100644
--- a/erpnext/healthcare/doctype/consultation/consultation.json
+++ b/erpnext/healthcare/doctype/consultation/consultation.json
@@ -216,7 +216,7 @@
    "label": "Gender", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "\nMale\nFemale", 
+   "options": "\nMale\nFemale\nOther", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 1, 
@@ -1004,7 +1004,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-10-05 12:13:52.596750", 
+ "modified": "2017-11-22 14:03:30.434304", 
  "modified_by": "Administrator", 
  "module": "Healthcare", 
  "name": "Consultation", 
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.json b/erpnext/healthcare/doctype/lab_test/lab_test.json
index 8677c82..721b095 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.json
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.json
@@ -114,7 +114,7 @@
    "columns": 0, 
    "fieldname": "patient_name", 
    "fieldtype": "Data", 
-   "hidden": 1, 
+   "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
@@ -185,7 +185,7 @@
    "label": "Gender", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "\nMale\nFemale", 
+   "options": "\nMale\nFemale\nOther", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 1, 
@@ -1388,7 +1388,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-10-05 12:14:57.078823", 
+ "modified": "2017-11-22 14:32:27.994634", 
  "modified_by": "Administrator", 
  "module": "Healthcare", 
  "name": "Lab Test", 
diff --git a/erpnext/healthcare/doctype/patient/patient.json b/erpnext/healthcare/doctype/patient/patient.json
index 6f9f2fc..21bef30 100644
--- a/erpnext/healthcare/doctype/patient/patient.json
+++ b/erpnext/healthcare/doctype/patient/patient.json
@@ -126,7 +126,7 @@
    "label": "Gender", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "\nMale\nFemale", 
+   "options": "\nMale\nFemale\nOther", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -185,7 +185,7 @@
    "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
-   "label": "DOB", 
+   "label": "Date of birth", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -359,37 +359,6 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "company", 
-   "fieldtype": "Link", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Company", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Company", 
-   "permlevel": 0, 
-   "precision": "", 
-   "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, 
-   "columns": 0, 
    "fieldname": "report_preference", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -884,7 +853,7 @@
    "label": "Marital Status", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "Single\nMarried\nDivorced\nWidow", 
+   "options": "\nSingle\nMarried\nDivorced\nWidow", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -1274,7 +1243,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 50, 
- "modified": "2017-10-04 17:41:03.219934", 
+ "modified": "2017-11-24 12:39:33.061005", 
  "modified_by": "Administrator", 
  "module": "Healthcare", 
  "name": "Patient", 
diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py
index f4d9a43..e73482d 100644
--- a/erpnext/healthcare/doctype/patient/patient.py
+++ b/erpnext/healthcare/doctype/patient/patient.py
@@ -69,7 +69,10 @@
 		frappe.db.set_value("Patient", self.name, "disabled", 0)
 		send_registration_sms(self)
 		if(frappe.get_value("Healthcare Settings", None, "registration_fee")>0):
-			sales_invoice = make_invoice(self.name, self.company)
+			company = frappe.defaults.get_user_default('company')
+			if not company:
+				company = frappe.db.get_value("Global Defaults", None, "default_company")
+			sales_invoice = make_invoice(self.name, company)
 			sales_invoice.save(ignore_permissions=True)
 			return {'invoice': sales_invoice.name}
 
@@ -110,7 +113,7 @@
 	return sales_invoice
 
 @frappe.whitelist()
-def get_patient_detail(patient, company=None):
+def get_patient_detail(patient):
 	patient_dict = frappe.db.sql("""select * from tabPatient where name=%s""", (patient), as_dict=1)
 	if not patient_dict:
 		frappe.throw("Patient not found")
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
index 2237ff5..a58516c 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
@@ -185,6 +185,7 @@
 	}
 	frappe.route_options = {
 		"patient": frm.doc.patient,
+		"appointment": frm.doc.name,
 	};
 	frappe.new_doc("Vital Signs");
 };
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
index 1663c5b..14c48b8 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
@@ -171,6 +171,100 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "depends_on": "", 
+   "fieldname": "patient_name", 
+   "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": "Patient Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "patient.patient_name", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "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": 0, 
+   "columns": 0, 
+   "fieldname": "patient_sex", 
+   "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": "Gender", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "patient.sex", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "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, 
+   "columns": 0, 
+   "fieldname": "patient_age", 
+   "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": "Patient Age", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "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": 0, 
+   "columns": 0, 
    "default": "Scheduled", 
    "fieldname": "status", 
    "fieldtype": "Select", 
@@ -446,158 +540,6 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "section_break_2", 
-   "fieldtype": "Section 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": "patient_details", 
-   "fieldtype": "Section 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, 
-   "label": "Patient Details", 
-   "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, 
-   "depends_on": "patient", 
-   "fieldname": "patient_name", 
-   "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": "Patient Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "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": 0, 
-   "columns": 0, 
-   "fieldname": "patient_sex", 
-   "fieldtype": "Data", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Gender", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "patient.sex", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "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, 
-   "columns": 0, 
-   "fieldname": "patient_age", 
-   "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": "Patient Age", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "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": 0, 
-   "columns": 0, 
    "fieldname": "company", 
    "fieldtype": "Link", 
    "hidden": 1, 
@@ -756,7 +698,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-10-25 23:33:36.060803", 
+ "modified": "2017-11-22 16:32:57.240736", 
  "modified_by": "Administrator", 
  "module": "Healthcare", 
  "name": "Patient Appointment", 
diff --git a/erpnext/healthcare/doctype/vital_signs/vital_signs.json b/erpnext/healthcare/doctype/vital_signs/vital_signs.json
index bab80f5..5f7fdd1 100644
--- a/erpnext/healthcare/doctype/vital_signs/vital_signs.json
+++ b/erpnext/healthcare/doctype/vital_signs/vital_signs.json
@@ -49,6 +49,37 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "patient_name", 
+   "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": "Patient Name", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "patient.patient_name", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "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": 0, 
+   "columns": 0, 
    "fieldname": "appointment", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -751,7 +782,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-10-04 16:08:36.340607", 
+ "modified": "2017-11-22 17:31:16.620650", 
  "modified_by": "Administrator", 
  "module": "Healthcare", 
  "name": "Vital Signs", 
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index fce9d65..1e98f39 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -448,6 +448,8 @@
 			for item in sorted(item_dict.values(), key=lambda d: d['idx']):
 				self.append('required_items', {
 					'item_code': item.item_code,
+					'item_name': item.item_name,
+					'description': item.description,
 					'required_qty': item.qty,
 					'source_warehouse': item.source_warehouse or item.default_warehouse
 				})
diff --git a/erpnext/manufacturing/report/production_order_stock_report/production_order_stock_report.py b/erpnext/manufacturing/report/production_order_stock_report/production_order_stock_report.py
index bb79a49..f996323 100644
--- a/erpnext/manufacturing/report/production_order_stock_report/production_order_stock_report.py
+++ b/erpnext/manufacturing/report/production_order_stock_report/production_order_stock_report.py
@@ -15,62 +15,66 @@
 	out = []
 	
 	#Add a row for each item/qty
-	for prod_order in prod_list:
-		prod_details = frappe.db.get_value("Production Order", prod_order.name, 
-			["bom_no", "source_warehouse", "qty", "produced_qty"], as_dict=1)
-		
+	for prod_details in prod_list:
 		desc = frappe.db.get_value("BOM", prod_details.bom_no, "description")
-		
-		item_list = frappe.db.sql("""SELECT 
-				bom_item.item_code as item_code,
-				ifnull(ledger.actual_qty*bom.quantity/bom_item.stock_qty,0) as build_qty
-			FROM
-				`tabBOM` as bom, `tabBOM Item` AS bom_item
-				LEFT JOIN `tabBin` AS ledger	
-					ON bom_item.item_code = ledger.item_code 
-					AND ledger.warehouse = ifnull(%(warehouse)s,%(filterhouse)s)
-			WHERE
-				bom.name = bom_item.parent
-				and bom.name = %(bom)s 
-			GROUP BY 
-				bom_item.item_code""", 
-		{"bom": prod_details.bom_no, "warehouse": prod_details.source_warehouse, 
-			"filterhouse": filters.warehouse}, as_dict=1)
-				
-		stock_qty = 0
-		count = 0
-		buildable_qty = prod_details.qty
-		for item in item_list:
-			count = count + 1
-			if item.build_qty >= (prod_details.qty - prod_details.produced_qty):
-				stock_qty = stock_qty + 1
-			elif buildable_qty >= item.build_qty:
-				buildable_qty = item.build_qty
-					
-		if count == stock_qty:
-			build = "Y"
-		else:
-			build = "N"
-		
-		row = frappe._dict({
-			"production_order": prod_order.name,
-			"status": prod_order.status,
-			"req_items": cint(count),
-			"instock": stock_qty,
-			"description": desc,
-			"bom_no": prod_details.bom_no,
-			"qty": prod_details.qty,
-			"buildable_qty": buildable_qty,
-			"ready_to_build": build
-		})
-		
-		out.append(row)
+
+		for prod_item_details in frappe.db.get_values("Production Order Item",
+			{"parent": prod_details.name}, ["item_code", "source_warehouse"], as_dict=1):
+
+			item_list = frappe.db.sql("""SELECT
+					bom_item.item_code as item_code,
+					ifnull(ledger.actual_qty*bom.quantity/bom_item.stock_qty,0) as build_qty
+				FROM
+					`tabBOM` as bom, `tabBOM Item` AS bom_item
+					LEFT JOIN `tabBin` AS ledger
+						ON bom_item.item_code = ledger.item_code
+						AND ledger.warehouse = ifnull(%(warehouse)s,%(filterhouse)s)
+				WHERE
+					bom.name = bom_item.parent
+					and bom_item.item_code = %(item_code)s
+					and bom.name = %(bom)s
+				GROUP BY
+					bom_item.item_code""",
+			{"bom": prod_details.bom_no, "warehouse": prod_item_details.source_warehouse,
+				"filterhouse": filters.warehouse, "item_code": prod_item_details.item_code}, as_dict=1)
+
+			stock_qty = 0
+			count = 0
+			buildable_qty = prod_details.qty
+			for item in item_list:
+				count = count + 1
+				if item.build_qty >= (prod_details.qty - prod_details.produced_qty):
+					stock_qty = stock_qty + 1
+				elif buildable_qty >= item.build_qty:
+					buildable_qty = item.build_qty
+
+			if count == stock_qty:
+				build = "Y"
+			else:
+				build = "N"
+
+			row = frappe._dict({
+				"production_order": prod_details.name,
+				"status": prod_details.status,
+				"req_items": cint(count),
+				"instock": stock_qty,
+				"description": desc,
+				"source_warehouse": prod_item_details.source_warehouse,
+				"item_code": prod_item_details.item_code,
+				"bom_no": prod_details.bom_no,
+				"qty": prod_details.qty,
+				"buildable_qty": buildable_qty,
+				"ready_to_build": build
+			})
+
+			out.append(row)
 
 	return out
 	
 def get_production_orders():
-	
-	out =  frappe.get_all("Production Order", filters={"docstatus": 1, "status": ( "!=","Completed")}, fields=["name","status"], order_by='name')
+	out =  frappe.get_all("Production Order", filters={"docstatus": 1, "status": ( "!=","Completed")},
+		fields=["name","status", "bom_no", "qty", "produced_qty"], order_by='name')
+
 	return out
 	
 def get_columns():
@@ -93,6 +97,18 @@
 		"options": "",
 		"width": 230
 	}, {
+		"fieldname": "item_code",
+		"label": "Item Code",
+		"fieldtype": "Link",
+		"options": "Item",
+		"width": 110
+	},{
+		"fieldname": "source_warehouse",
+		"label": "Source Warehouse",
+		"fieldtype": "Link",
+		"options": "Warehouse",
+		"width": 110
+	},{
 		"fieldname": "qty",
 		"label": "Qty to Build",
 		"fieldtype": "Data",
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index b7a4099..fcf5cfc 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -470,3 +470,6 @@
 erpnext.patches.v9_0.set_shipping_type_for_existing_shipping_rules
 erpnext.patches.v9_0.update_multi_uom_fields_in_material_request
 erpnext.patches.v10_0.rename_schools_to_education
+erpnext.patches.v9_2.repost_reserved_qty_for_production
+erpnext.patches.v9_2.remove_company_from_patient
+erpnext.patches.v9_2.set_item_name_in_production_order
diff --git a/erpnext/patches/v9_2/remove_company_from_patient.py b/erpnext/patches/v9_2/remove_company_from_patient.py
new file mode 100644
index 0000000..ad9c9c5
--- /dev/null
+++ b/erpnext/patches/v9_2/remove_company_from_patient.py
@@ -0,0 +1,5 @@
+import frappe
+
+def execute():
+	if 'company' in frappe.db.get_table_columns("Patient"):
+		frappe.db.sql("alter table `tabPatient` drop column company")
diff --git a/erpnext/patches/v9_2/repost_reserved_qty_for_production.py b/erpnext/patches/v9_2/repost_reserved_qty_for_production.py
new file mode 100644
index 0000000..27cce1d
--- /dev/null
+++ b/erpnext/patches/v9_2/repost_reserved_qty_for_production.py
@@ -0,0 +1,7 @@
+import frappe
+
+def execute():
+	bins = frappe.db.sql("select name from `tabBin` where reserved_qty_for_production > 0")
+	for d in bins:
+		bin_doc = frappe.get_doc("Bin", d[0])
+		bin_doc.update_reserved_qty_for_production()
\ No newline at end of file
diff --git a/erpnext/patches/v9_2/set_item_name_in_production_order.py b/erpnext/patches/v9_2/set_item_name_in_production_order.py
new file mode 100644
index 0000000..e0e422b
--- /dev/null
+++ b/erpnext/patches/v9_2/set_item_name_in_production_order.py
@@ -0,0 +1,11 @@
+import frappe
+
+def execute():
+
+	frappe.db.sql("""
+		update `tabBOM Item` bom, `tabProduction Order Item` po_item
+		set po_item.item_name = bom.item_name,
+			po_item.description = bom.description
+		where po_item.item_code = bom.item_code
+			and (po_item.item_name is null or po_item.description is null)
+	""")
diff --git a/erpnext/setup/doctype/party_type/party_type.json b/erpnext/setup/doctype/party_type/party_type.json
index ee4b8ea..e1814ae 100644
--- a/erpnext/setup/doctype/party_type/party_type.json
+++ b/erpnext/setup/doctype/party_type/party_type.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
  "allow_import": 0, 
  "allow_rename": 0, 
  "autoname": "field:party_type", 
@@ -13,6 +14,7 @@
  "engine": "InnoDB", 
  "fields": [
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -43,17 +45,17 @@
    "unique": 0
   }
  ], 
+ "has_web_view": 0, 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "idx": 0, 
  "image_view": 0, 
- "in_create": 0, 
- "in_dialog": 0, 
+ "in_create": 1, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-02-20 13:25:04.456818", 
+ "modified": "2017-11-23 17:46:27.075001", 
  "modified_by": "Administrator", 
  "module": "Setup", 
  "name": "Party Type", 
@@ -64,8 +66,8 @@
    "amend": 0, 
    "apply_user_permissions": 0, 
    "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
+   "create": 0, 
+   "delete": 0, 
    "email": 1, 
    "export": 1, 
    "if_owner": 0, 
@@ -78,14 +80,14 @@
    "set_user_permissions": 0, 
    "share": 1, 
    "submit": 0, 
-   "write": 1
+   "write": 0
   }, 
   {
    "amend": 0, 
    "apply_user_permissions": 0, 
    "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
+   "create": 0, 
+   "delete": 0, 
    "email": 1, 
    "export": 1, 
    "if_owner": 0, 
@@ -98,14 +100,14 @@
    "set_user_permissions": 0, 
    "share": 1, 
    "submit": 0, 
-   "write": 1
+   "write": 0
   }, 
   {
    "amend": 0, 
    "apply_user_permissions": 0, 
    "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
+   "create": 0, 
+   "delete": 0, 
    "email": 1, 
    "export": 1, 
    "if_owner": 0, 
@@ -118,10 +120,10 @@
    "set_user_permissions": 0, 
    "share": 1, 
    "submit": 0, 
-   "write": 1
+   "write": 0
   }
  ], 
- "quick_entry": 1, 
+ "quick_entry": 0, 
  "read_only": 0, 
  "read_only_onload": 0, 
  "show_name_in_global_search": 1, 
diff --git a/erpnext/setup/doctype/party_type/test_party_type.js b/erpnext/setup/doctype/party_type/test_party_type.js
new file mode 100644
index 0000000..c97dbc5
--- /dev/null
+++ b/erpnext/setup/doctype/party_type/test_party_type.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Party Type", function (assert) {
+	let done = assert.async();
+
+	// number of asserts
+	assert.expect(1);
+
+	frappe.run_serially([
+		// insert a new Party Type
+		() => frappe.tests.make('Party Type', [
+			// values to be set
+			{key: 'value'}
+		]),
+		() => {
+			assert.equal(cur_frm.doc.key, 'value');
+		},
+		() => done()
+	]);
+
+});
diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py
index 626a9db..fbbe6ee 100644
--- a/erpnext/stock/doctype/bin/bin.py
+++ b/erpnext/stock/doctype/bin/bin.py
@@ -88,11 +88,10 @@
 				and item.source_warehouse = %s
 				and pro.status not in ("Stopped", "Completed")''', (self.item_code, self.warehouse))[0][0]
 
-		if self.reserved_qty_for_production:
-			self.set_projected_qty()
+		self.set_projected_qty()
 
-			self.db_set('reserved_qty_for_production', self.reserved_qty_for_production)
-			self.db_set('projected_qty', self.projected_qty)
+		self.db_set('reserved_qty_for_production', flt(self.reserved_qty_for_production))
+		self.db_set('projected_qty', self.projected_qty)
 
 
 def update_item_projected_qty(item_code):
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index e5cd2fe..15b903e 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -410,11 +410,11 @@
 @frappe.whitelist()
 def get_pos_profile(company):
 	pos_profile = frappe.db.sql("""select * from `tabPOS Profile` where user = %s
-		 and company = %s""", (frappe.session['user'], company), as_dict=1)
+		and company = %s and ifnull(disabled,0) != 1""", (frappe.session['user'], company), as_dict=1)
 
 	if not pos_profile:
 		pos_profile = frappe.db.sql("""select * from `tabPOS Profile`
-			where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
+			where ifnull(user,'') = '' and company = %s and ifnull(disabled,0) != 1""", company, as_dict=1)
 
 	return pos_profile and pos_profile[0] or None