Fixed version conflict
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 5dce71f..db6d594 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -403,9 +403,9 @@
 	def validate_warehouse(self):
 		super(SalesInvoice, self).validate_warehouse()
 
-		for d in self.get('items'):
+		for d in self.get_item_list():
 			if not d.warehouse and frappe.db.get_value("Item", d.item_code, "is_stock_item"):
-				frappe.throw(_("Warehouse required at Row No {0}").format(d.idx))
+				frappe.throw(_("Warehouse required for stock Item {0}").format(d.item_code))
 
 	def validate_delivery_note(self):
 		for d in self.get("items"):
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index b2b6aea..a4078bd 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -547,26 +547,34 @@
 		}
 	},
 
-	update_qty: function() {
+	bind_qty_event: function() {
 		var me = this;
 
 		$(this.wrapper).find(".pos-item-qty").on("change", function(){
 			var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
-			me.update_qty_rate_against_item_code(item_code, "qty", $(this).val());
+			var qty = $(this).val();
+			me.update_qty(item_code, qty)
 		})
 
 		$(this.wrapper).find("[data-action='increase-qty']").on("click", function(){
 			var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
 			var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) + 1;
-			me.update_qty_rate_against_item_code(item_code, "qty", qty);
+			me.update_qty(item_code, qty)
 		})
 
 		$(this.wrapper).find("[data-action='decrease-qty']").on("click", function(){
 			var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
 			var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) - 1;
-			me.update_qty_rate_against_item_code(item_code, "qty", qty);
+			me.update_qty(item_code, qty)
 		})
 	},
+	
+	update_qty: function(item_code, qty) {
+		var me = this;
+		this.items = this.get_items(item_code);
+		this.validate_serial_no()
+		this.update_qty_rate_against_item_code(item_code, "qty", qty);
+	},
 
 	update_rate: function() {
 		var me = this;
@@ -721,7 +729,7 @@
 	refresh: function(update_paid_amount) {
 		var me = this;
 		this.refresh_fields(update_paid_amount);
-		this.update_qty();
+		this.bind_qty_event();
 		this.update_rate();
 		this.set_primary_action();
 	},
@@ -1017,6 +1025,13 @@
 			serial_no = me.item_serial_no[key][0];
 		}
 
+		if(this.items[0].has_serial_no && serial_no == ""){
+			this.refresh();
+			frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", {
+				'item': this.items[0].item_code
+			})))
+		}
+
 		if(item_code && serial_no){
 			$.each(this.frm.doc.items, function(index, data){
 				if(data.item_code == item_code){
@@ -1028,12 +1043,6 @@
 				}
 			})
 		}
-
-		if(this.items[0].has_serial_no && serial_no == ""){
-			frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", {
-				'item': this.items[0].item_code
-			})))
-		}
 	},
 
 	validate_serial_no_qty: function(args, item_code, field, value){
@@ -1045,11 +1054,13 @@
 			frappe.throw(__("Serial no item cannot be a fraction"))
 		}
 
-		if(args.serial_no && args.serial_no.split('\n').length != cint(value)){
+		if(args.item_code == item_code && args.serial_no && args.serial_no.split('\n').length != cint(value)){
 			args.qty = 0.0;
 			args.serial_no = ''
 			this.refresh();
-			frappe.throw(__("Total nos of serial no is not equal to quantity."))
+			frappe.throw(__(repl("Total nos of serial no is not equal to quantity for item %(item)s.", {
+				'item': item_code
+			})))
 		}
 	},
 
diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py
index ba1d242..66b3dd0 100644
--- a/erpnext/controllers/item_variant.py
+++ b/erpnext/controllers/item_variant.py
@@ -41,30 +41,37 @@
 
 		if attribute.lower() in numeric_values:
 			numeric_attribute = numeric_values[attribute.lower()]
+			validate_is_incremental(numeric_attribute, attribute, value, item.name)
 
-			from_range = numeric_attribute.from_range
-			to_range = numeric_attribute.to_range
-			increment = numeric_attribute.increment
+		else:
+			attributes_list = attribute_values.get(attribute.lower(), [])
+			validate_item_attribute_value(attributes_list, attribute, value, item.name)
 
-			if increment == 0:
-				# defensive validation to prevent ZeroDivisionError
-				frappe.throw(_("Increment for Attribute {0} cannot be 0").format(attribute))
+def validate_is_incremental(numeric_attribute, attribute, value, item):
+	from_range = numeric_attribute.from_range
+	to_range = numeric_attribute.to_range
+	increment = numeric_attribute.increment
 
-			is_in_range = from_range <= flt(value) <= to_range
-			precision = max(len(cstr(v).split(".")[-1].rstrip("0")) for v in (value, increment))
-			#avoid precision error by rounding the remainder
-			remainder = flt((flt(value) - from_range) % increment, precision)
+	if increment == 0:
+		# defensive validation to prevent ZeroDivisionError
+		frappe.throw(_("Increment for Attribute {0} cannot be 0").format(attribute))
 
-			is_incremental = remainder==0 or remainder==increment
+	is_in_range = from_range <= flt(value) <= to_range
+	precision = max(len(cstr(v).split(".")[-1].rstrip("0")) for v in (value, increment))
+	#avoid precision error by rounding the remainder
+	remainder = flt((flt(value) - from_range) % increment, precision)
 
-			if not (is_in_range and is_incremental):
-				frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3} for Item {4}")\
-					.format(attribute, from_range, to_range, increment, item.name),
-					InvalidItemAttributeValueError, title=_('Invalid Attribute'))
+	is_incremental = remainder==0 or remainder==increment
 
-		elif value not in attribute_values.get(attribute.lower(), []):
-			frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values for Item {2}").format(
-				value, attribute, item.name), InvalidItemAttributeValueError, title=_('Invalid Attribute'))
+	if not (is_in_range and is_incremental):
+		frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3} for Item {4}")\
+			.format(attribute, from_range, to_range, increment, item),
+			InvalidItemAttributeValueError, title=_('Invalid Attribute'))
+
+def validate_item_attribute_value(attributes_list, attribute, attribute_value, item):
+	if attribute_value not in attributes_list:
+		frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values for Item {2}").format(
+			attribute_value, attribute, item), InvalidItemAttributeValueError, title=_('Invalid Attribute'))
 
 def get_attribute_values():
 	if not frappe.flags.attribute_values:
diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.json b/erpnext/hr/doctype/hr_settings/hr_settings.json
index 74c4273..e9d2098 100644
--- a/erpnext/hr/doctype/hr_settings/hr_settings.json
+++ b/erpnext/hr/doctype/hr_settings/hr_settings.json
@@ -14,6 +14,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "employee_settings", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -28,6 +29,7 @@
    "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, 
@@ -38,6 +40,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "", 
    "description": "Enter retirement age in years", 
    "fieldname": "retirement_age", 
@@ -55,6 +58,7 @@
    "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, 
@@ -65,6 +69,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "Naming Series", 
    "description": "Employee record is created using selected field. ", 
    "fieldname": "emp_created_by", 
@@ -82,6 +87,7 @@
    "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, 
@@ -92,6 +98,33 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "column_break_4", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 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_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "description": "Don't send Employee Birthday Reminders", 
    "fieldname": "stop_birthday_reminders", 
    "fieldtype": "Check", 
@@ -107,6 +140,7 @@
    "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, 
@@ -117,6 +151,34 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "maintain_bill_work_hours_same", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Maintain Billing Hours and Working Hours Same on Timesheet", 
+   "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_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "payroll_settings", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -131,6 +193,7 @@
    "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, 
@@ -141,6 +204,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "description": "If checked, Total no. of Working Days will include holidays, and this will reduce the value of Salary Per Day", 
    "fieldname": "include_holidays_in_total_working_days", 
    "fieldtype": "Check", 
@@ -156,6 +220,7 @@
    "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, 
@@ -166,6 +231,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "1", 
    "description": "Emails salary slip to employee based on preferred email selected in Employee", 
    "fieldname": "email_salary_slip_to_employee", 
@@ -183,6 +249,7 @@
    "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, 
@@ -193,6 +260,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "max_working_hours_against_timesheet", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -208,6 +276,7 @@
    "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, 
@@ -226,7 +295,7 @@
  "issingle": 1, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-09-21 11:28:50.687129", 
+ "modified": "2016-12-21 18:52:03.633251", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "HR Settings", 
@@ -242,6 +311,7 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
+   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
diff --git a/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py b/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py
index 5c63c00..321b039 100644
--- a/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py
+++ b/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py
@@ -3,6 +3,9 @@
 from erpnext.stock.stock_balance import repost_stock
 
 def execute():
+	frappe.reload_doc('manufacturing', 'doctype', 'production_order_item')
+	frappe.reload_doc('manufacturing', 'doctype', 'production_order')
+	
 	modified_items = frappe.db.sql_list("""
 		select name from `tabItem` 
 		where is_stock_item=1 and modified >= '2016-10-31'
diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js
index 93f8b68..01fa160 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.js
+++ b/erpnext/projects/doctype/timesheet/timesheet.js
@@ -136,7 +136,7 @@
 	frappe.model.set_value(cdt, cdn, "to_time", d.format(moment.defaultDatetimeFormat));
 	frm._setting_hours = false;
 
-	if(frm.doc.__islocal && !child.billing_hours && child.hours){
+	if((frm.doc.__islocal || frm.doc.__onload.maintain_bill_work_hours_same) && child.hours){
 		frappe.model.set_value(cdt, cdn, "billing_hours", child.hours);
 	}
 }
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index 48d3e00..c3dbcd4 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -20,6 +20,9 @@
 class OverProductionLoggedError(frappe.ValidationError): pass
 
 class Timesheet(Document):
+	def onload(self):
+		self.get("__onload").maintain_bill_work_hours_same = frappe.db.get_single_value('HR Settings', 'maintain_bill_work_hours_same')
+
 	def validate(self):
 		self.set_employee_name()
 		self.set_status()
diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.py b/erpnext/setup/doctype/sms_settings/sms_settings.py
index d0f4065..681237f 100644
--- a/erpnext/setup/doctype/sms_settings/sms_settings.py
+++ b/erpnext/setup/doctype/sms_settings/sms_settings.py
@@ -69,7 +69,7 @@
 
 def send_via_gateway(arg):
 	ss = frappe.get_doc('SMS Settings', 'SMS Settings')
-	args = {ss.message_parameter : arg.get('message')}
+	args = {ss.message_parameter: arg.get('message')}
 	for d in ss.get("parameters"):
 		args[d.parameter] = d.value
 
@@ -77,7 +77,7 @@
 	for d in arg.get('receiver_list'):
 		args[ss.receiver_parameter] = d
 		status = send_request(ss.sms_gateway_url, args)
-		if status == 200:
+		if status > 200 and status < 300:
 			success_list.append(d)
 
 	if len(success_list) > 0:
@@ -85,27 +85,12 @@
 		create_sms_log(args, success_list)
 		frappe.msgprint(_("SMS sent to following numbers: {0}").format("\n" + "\n".join(success_list)))
 
-# Send Request
-# =========================================================
-def send_request(gateway_url, args):
-	import httplib, urllib
-	server, api_url = scrub_gateway_url(gateway_url)
-	conn = httplib.HTTPConnection(server)  # open connection
-	headers = {}
-	headers['Accept'] = "text/plain, text/html, */*"
-	conn.request('GET', api_url + urllib.urlencode(args), headers = headers)    # send request
-	resp = conn.getresponse()     # get response
-	return resp.status
 
-# Split gateway url to server and api url
-# =========================================================
-def scrub_gateway_url(url):
-	url = url.replace('http://', '').strip().split('/')
-	server = url.pop(0)
-	api_url = '/' + '/'.join(url)
-	if not api_url.endswith('?'):
-		api_url += '?'
-	return server, api_url
+def send_request(gateway_url, params):
+	import requests
+	response = requests.get(gateway_url, params = params, headers={'Accept': "text/plain, text/html, */*"})
+	response.raise_for_status()
+	return response.status_code
 
 
 # Create SMS Log
diff --git a/erpnext/stock/doctype/item_attribute/item_attribute.py b/erpnext/stock/doctype/item_attribute/item_attribute.py
index 3220bc5..71b998f 100644
--- a/erpnext/stock/doctype/item_attribute/item_attribute.py
+++ b/erpnext/stock/doctype/item_attribute/item_attribute.py
@@ -6,7 +6,8 @@
 from frappe.model.document import Document
 from frappe import _
 
-from erpnext.controllers.item_variant import validate_item_variant_attributes, InvalidItemAttributeValueError
+from erpnext.controllers.item_variant import (validate_is_incremental,
+	validate_item_attribute_value, InvalidItemAttributeValueError)
 
 
 class ItemAttributeIncrementError(frappe.ValidationError): pass
@@ -25,9 +26,15 @@
 
 	def validate_exising_items(self):
 		'''Validate that if there are existing items with attributes, they are valid'''
-		for item in frappe.db.sql('''select distinct i.name from `tabItem Variant Attribute` iva, `tabItem` i
-			where iva.attribute = %s and iva.parent = i.name and i.has_variants = 0''', self.name):
-			validate_item_variant_attributes(item[0])
+		attributes_list = [d.attribute_value for d in self.item_attribute_values]
+
+		for item in frappe.db.sql('''select i.name, iva.attribute_value as value
+			from `tabItem Variant Attribute` iva, `tabItem` i where iva.attribute = %s
+			and iva.parent = i.name and i.has_variants = 0''', self.name, as_dict=1):
+			if self.numeric_values:
+				validate_is_incremental(self, self.name, item.value, item.name)
+			else:
+				validate_item_attribute_value(attributes_list, self.name, item.value, item.name)
 
 	def validate_numeric(self):
 		if self.numeric_values: