Merge pull request #6819 from rohitwaghchaure/hotfix_issues

cleanup and fixes
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 9d71908..5337395 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.1.6'
+__version__ = '7.1.7'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index 4c13fe3..32e9b3a 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -988,6 +988,10 @@
 				item.margin_rate_or_amount = pricing_rule[0].margin_rate_or_amount;
 				item.discount_percentage = pricing_rule[0].discount_percentage || 0.0;
 				me.apply_pricing_rule_on_item(item)
+			} else if(item.discount_percentage > 0 || item.margin_rate_or_amount > 0) {
+				item.margin_rate_or_amount = 0.0;
+				item.discount_percentage = 0.0;
+				me.apply_pricing_rule_on_item(item)
 			}
 		})
 	},
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.json b/erpnext/hr/doctype/salary_slip/salary_slip.json
index c54e039..f660b78 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.json
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.json
@@ -129,22 +129,23 @@
    "collapsible": 0, 
    "columns": 0, 
    "fieldname": "department", 
-   "fieldtype": "Link", 
+   "fieldtype": "Read Only", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Department", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldname": "department", 
    "oldfieldtype": "Link", 
-   "options": "Department", 
+   "options": "employee.department", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
-   "read_only": 1, 
+   "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -157,23 +158,25 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "depends_on": "eval:doc.designation", 
    "fieldname": "designation", 
-   "fieldtype": "Link", 
+   "fieldtype": "Read Only", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Designation", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldname": "designation", 
    "oldfieldtype": "Link", 
-   "options": "Designation", 
+   "options": "employee.designation", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
-   "read_only": 1, 
+   "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -187,22 +190,23 @@
    "collapsible": 0, 
    "columns": 0, 
    "fieldname": "branch", 
-   "fieldtype": "Link", 
+   "fieldtype": "Read Only", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Branch", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldname": "branch", 
    "oldfieldtype": "Link", 
-   "options": "Branch", 
+   "options": "employee.branch", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
-   "read_only": 1, 
+   "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -1344,7 +1348,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-11-03 16:02:55.891380", 
+ "modified": "2016-11-06 09:54:36.478329", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Slip", 
diff --git a/erpnext/patches/v5_1/rename_roles.py b/erpnext/patches/v5_1/rename_roles.py
index 452c800..26208aa 100644
--- a/erpnext/patches/v5_1/rename_roles.py
+++ b/erpnext/patches/v5_1/rename_roles.py
@@ -5,5 +5,5 @@
 		frappe.rename_doc("Role", "Material User", "Stock User")
 	if not frappe.db.exists("Role", "Stock Manager"):
 		frappe.rename_doc("Role", "Material Manager", "Stock Manager")
-	if not frappe.db.exists("Role", "Stock Manager"):
+	if not frappe.db.exists("Role", "Item Manager"):
 		frappe.rename_doc("Role", "Material Master Manager", "Item Manager")
diff --git a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
index 2ca72b4..9894c2a 100644
--- a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
+++ b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
@@ -3,11 +3,12 @@
 	import make_timesheet, add_timesheet_detail
 
 def execute():
+	frappe.reload_doc('projects', 'doctype', 'task')
 	frappe.reload_doc('projects', 'doctype', 'timesheet')
 	if not frappe.db.table_exists("Time Log"):
 		return
 
-	for data in frappe.db.sql("select * from `tabTime Log` where docstatus < 2", as_dict=1):
+	for data in frappe.db.sql("select * from `tabTime Log`", as_dict=1):
 		if data.task:
 			company = frappe.db.get_value("Task", data.task, "company")
 		elif data.production_order:
@@ -18,7 +19,10 @@
 		time_sheet = make_timesheet(data.production_order)
 		args = get_timelog_data(data)
 		add_timesheet_detail(time_sheet, args)
-		time_sheet.docstatus = data.docstatus
+		if data.docstatus == 2:
+			time_sheet.docstatus = 0
+		else:
+			time_sheet.docstatus = data.docstatus
 		time_sheet.employee = data.employee
 		time_sheet.note = data.note
 		time_sheet.company = company
@@ -38,6 +42,10 @@
 				d.db_set("docstatus", 1)
 			time_sheet.update_production_order(time_sheet.name)
 			time_sheet.update_task_and_project()
+		if data.docstatus == 2:
+			time_sheet.db_set("docstatus", 2)
+			for d in time_sheet.get("time_logs"):
+				d.db_set("docstatus", 2)
 
 def get_timelog_data(data):
 	return {