Merge pull request #7290 from netchampfaris/pos-item-area-scroll

pos item area scrollable
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index f91c97a..2109792 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.1.28'
+__version__ = '7.2.1'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
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 5290caf..c52d4fa 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -298,7 +298,7 @@
 		this.pos_profile_data = r.message.pos_profile;
 		this.default_customer = r.message.default_customer || null;
 		this.print_settings = locals[":Print Settings"]["Print Settings"];
-		this.letter_head = frappe.boot.letter_heads[this.pos_profile_data[letter_head]] || {};
+		this.letter_head = (this.pos_profile_data.length > 0) ? frappe.boot.letter_heads[this.pos_profile_data[letter_head]] : {};
 	},
 
 	save_previous_entry : function(){
@@ -549,26 +549,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;
@@ -723,7 +731,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();
 	},
@@ -1019,6 +1027,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){
@@ -1030,12 +1045,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){
@@ -1047,11 +1056,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/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js
index fe83f40..c24a6bc 100755
--- a/erpnext/hr/doctype/employee/employee.js
+++ b/erpnext/hr/doctype/employee/employee.js
@@ -48,8 +48,8 @@
 
 });
 frappe.ui.form.on('Employee',{
-	prefered_contact_email:function(frm){
-		frm.events.update_contact(frm)
+	prefered_contact_email:function(frm){		
+		frm.events.update_contact(frm)		
 	},
 	personal_email:function(frm){
 		frm.events.update_contact(frm)
@@ -74,5 +74,19 @@
 			}
 		});
 	},
+	create_user: function(frm) {
+		if (!frm.doc.prefered_email)
+		{
+			frappe.throw(__("Please enter Preferred Contact Email"))
+		}
+		frappe.call({
+			method: "erpnext.hr.doctype.employee.employee.create_user",
+			args: { employee: cur_frm.doc.name },
+			callback: function(r)
+			{
+				frm.set_value("user_id", r.message)
+			}
+		});
+	}
 });
 cur_frm.cscript = new erpnext.hr.EmployeeController({frm: cur_frm});
diff --git a/erpnext/hr/doctype/employee/employee.json b/erpnext/hr/doctype/employee/employee.json
index 5ded5a0..62ca61c 100644
--- a/erpnext/hr/doctype/employee/employee.json
+++ b/erpnext/hr/doctype/employee/employee.json
@@ -217,6 +217,35 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "depends_on": "eval:(!doc.user_id)", 
+   "fieldname": "create_user", 
+   "fieldtype": "Button", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Create User", 
+   "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": "image", 
    "fieldtype": "Attach Image", 
    "hidden": 1, 
@@ -2244,7 +2273,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-11-07 05:15:16.925799", 
+ "modified": "2016-12-19 17:24:22.941738", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Employee", 
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index 58d1262..881853d 100755
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -6,7 +6,7 @@
 
 from frappe.utils import getdate, validate_email_add, today, add_years
 from frappe.model.naming import make_autoname
-from frappe import throw, _
+from frappe import throw, _, scrub
 import frappe.permissions
 from frappe.model.document import Document
 from erpnext.utilities.transaction_base import delete_events
@@ -39,6 +39,7 @@
 		self.validate_status()
 		self.validate_employee_leave_approver()
 		self.validate_reports_to()
+		self.validate_prefered_email()
 
 		if self.user_id:
 			self.validate_for_enabled_user_id()
@@ -153,6 +154,11 @@
 	def on_trash(self):
 		delete_events(self.doctype, self.name)
 
+	def validate_prefered_email(self):
+		if not self.get(scrub(self.prefered_contact_email)):
+			frappe.msgprint(_("Please enter " + self.prefered_contact_email))
+
+
 def get_timeline_data(doctype, name):
 	'''Return timeline for attendance'''
 	return dict(frappe.db.sql('''select unix_timestamp(att_date), count(*)
@@ -250,3 +256,34 @@
 		sales_person = frappe.db.get_value("Sales Person", {"Employee": employee})
 		if sales_person:
 			frappe.db.set_value("Sales Person", sales_person, "enabled", 0)
+
+@frappe.whitelist()
+def create_user(employee, user = None):
+	emp = frappe.get_doc("Employee", employee)
+
+	employee_name = emp.employee_name.split(" ")
+	middle_name = last_name = ""
+
+	if len(employee_name) >= 3:
+		last_name = " ".join(employee_name[2:])
+		middle_name = employee_name[1]
+	elif len(employee_name) == 2:
+		last_name = employee_name[1]
+
+	first_name = employee_name[0]
+	
+	user = frappe.new_doc("User")
+	user.update({
+		"name": emp.employee_name,
+		"email": emp.prefered_email,
+		"enabled": 1,
+		"first_name": first_name,
+		"middle_name": middle_name,
+		"last_name": last_name,
+		"gender": emp.gender,
+		"birth_date": emp.date_of_birth,
+		"phone": emp.cell_number,
+		"bio": emp.bio
+	})
+	user.insert()
+	return user.name
\ No newline at end of file
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 d1974d2..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
@@ -4,6 +4,7 @@
 
 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` 
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/schools/doctype/student_leave_application/student_leave_application.json b/erpnext/schools/doctype/student_leave_application/student_leave_application.json
index f183afc..ad6d498 100644
--- a/erpnext/schools/doctype/student_leave_application/student_leave_application.json
+++ b/erpnext/schools/doctype/student_leave_application/student_leave_application.json
@@ -103,7 +103,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "date", 
+   "fieldname": "from_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
@@ -111,7 +111,7 @@
    "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 1, 
-   "label": "Date", 
+   "label": "From Date", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -131,6 +131,63 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "to_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "To Date", 
+   "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": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "description": "Will show the student as Present in Student Monthly Attendance Report", 
+   "fieldname": "mark_as_present", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Mark as Present", 
+   "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": "section_break_5", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -220,7 +277,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-12-15 14:51:28.774955", 
+ "modified": "2016-12-21 18:58:00.256114", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student Leave Application", 
diff --git a/erpnext/schools/report/absent_student_report/absent_student_report.py b/erpnext/schools/report/absent_student_report/absent_student_report.py
index 82a20aa..32026c9 100644
--- a/erpnext/schools/report/absent_student_report/absent_student_report.py
+++ b/erpnext/schools/report/absent_student_report/absent_student_report.py
@@ -55,6 +55,6 @@
 def get_leave_applications(date):
 	leave_applicants = []
 	for student in frappe.db.sql("""select student from `tabStudent Leave Application` 
-		where docstatus = 1 and date = %s""", date):
+	where docstatus = 1 and from_date <= %s and to_date >= %s""", (date, date)):
 		leave_applicants.append(student[0])
 	return leave_applicants
\ No newline at end of file
diff --git a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.js b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.js
index 32c0551..8d914cb 100644
--- a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.js
+++ b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.js
@@ -3,40 +3,40 @@
 
 
 frappe.query_reports["Student Monthly Attendance Sheet"] = {
-	"filters": [
-		{
-			"fieldname":"month",
-			"label": __("Month"),
-			"fieldtype": "Select",
-			"options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
-			"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
-				"Dec"][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()],
-		},
-		{
-			"fieldname":"year",
-			"label": __("Year"),
-			"fieldtype": "Select",
-			"reqd": 1
-		},
-		{
-			"fieldname":"student_batch",
-			"label": __("Student Batch"),
-			"fieldtype": "Link",
-			"options": "Student Batch",
-			"reqd": 1
-		}
-	],
+    "filters": [{
+            "fieldname": "month",
+            "label": __("Month"),
+            "fieldtype": "Select",
+            "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
+            "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
+                "Dec"
+            ][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()],
+        },
+        {
+            "fieldname": "year",
+            "label": __("Year"),
+            "fieldtype": "Select",
+            "reqd": 1
+        },
+        {
+            "fieldname": "student_batch",
+            "label": __("Student Batch"),
+            "fieldtype": "Link",
+            "options": "Student Batch",
+            "reqd": 1
+        }
+    ],
 
-	"onload": function() {
-		return  frappe.call({
-			method: "erpnext.schools.report.student_monthly_attendance_sheet.student_monthly_attendance_sheet.get_attendance_years",
-			callback: function(r) {
-				var year_filter = frappe.query_report_filters_by_name.year;
-				year_filter.df.options = r.message;
-				year_filter.df.default = r.message.split("\n")[0];
-				year_filter.refresh();
-				year_filter.set_input(year_filter.df.default);
-			}
-		});
-	}
-}
+    "onload": function() {
+        return frappe.call({
+            method: "erpnext.schools.report.student_monthly_attendance_sheet.student_monthly_attendance_sheet.get_attendance_years",
+            callback: function(r) {
+                var year_filter = frappe.query_report_filters_by_name.year;
+                year_filter.df.options = r.message;
+                year_filter.df.default = r.message.split("\n")[0];
+                year_filter.refresh();
+                year_filter.set_input(year_filter.df.default);
+            }
+        });
+    }
+}
\ No newline at end of file
diff --git a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py
index 2f8ba52..01cee58 100644
--- a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py
+++ b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py
@@ -3,7 +3,7 @@
 
 from __future__ import unicode_literals
 import frappe
-from frappe.utils import cstr, cint, getdate
+from frappe.utils import cstr, cint, getdate, get_first_day, get_last_day, date_diff, add_days
 from frappe import msgprint, _
 from calendar import monthrange
 from erpnext.schools.api import get_student_batch_students
@@ -11,72 +11,93 @@
 def execute(filters=None):
 	if not filters: filters = {}
 
-	conditions, filters = get_conditions(filters)
-	columns = get_columns(filters)
-	att_map = get_attendance_list(conditions, filters)
+	from_date = get_first_day(filters["month"] + '-' + filters["year"])
+	to_date = get_last_day(filters["month"] + '-' + filters["year"])
+	total_days_in_month = date_diff(to_date, from_date) +1
+	columns = get_columns(total_days_in_month)
 	students = get_student_batch_students(filters.get("student_batch"))
+	students_list = get_students_list(students)
+	att_map = get_attendance_list(from_date, to_date, filters.get("student_batch"), students_list)
 	data = []
 	for stud in students:
 		row = [stud.student, stud.student_name]
-
+		date = from_date
 		total_p = total_a = 0.0
-		for day in range(filters["total_days_in_month"]):
+		for day in range(total_days_in_month):
 			status="None"
 			if att_map.get(stud.student):
-				status = att_map.get(stud.student).get(day + 1, "None")
+				status = att_map.get(stud.student).get(date, "None")
 			status_map = {"Present": "P", "Absent": "A", "None": ""}
 			row.append(status_map[status])
-
 			if status == "Present":
 				total_p += 1
 			elif status == "Absent":
 				total_a += 1
-
+			date = add_days(date, 1)
 		row += [total_p, total_a]
 		data.append(row)
-
 	return columns, data
 
-def get_columns(filters):
+def get_columns(days_in_month):
 	columns = [ _("Student") + ":Link/Student:90", _("Student Name") + "::150"]
-
-	for day in range(filters["total_days_in_month"]):
+	for day in range(days_in_month):
 		columns.append(cstr(day+1) +"::20")
-
 	columns += [_("Total Present") + ":Int:95", _("Total Absent") + ":Int:90"]
 	return columns
 
-def get_attendance_list(conditions, filters):
-	attendance_list = frappe.db.sql("""select student, day(date) as day_of_month,
-		status from `tabStudent Attendance` where docstatus = 1 %s order by student, date""" %
-		conditions, filters, as_dict=1)
+def get_students_list(students):
+	student_list = []
+	for stud in students:
+		student_list.append(stud.student)
+	return student_list
 
+def get_attendance_list(from_date, to_date, student_batch, students_list):
+	attendance_list = frappe.db.sql("""select student, date, status 
+		from `tabStudent Attendance` where docstatus = 1 and student_batch = %s 
+		and date between %s and %s
+		order by student, date""",
+		(student_batch, from_date, to_date), as_dict=1)
 	att_map = {}
+	students_with_leave_application = get_students_with_leave_application(from_date, to_date, students_list)
 	for d in attendance_list:
-		att_map.setdefault(d.student, frappe._dict()).setdefault(d.day_of_month, "")
-		att_map[d.student][d.day_of_month] = d.status
-
+		att_map.setdefault(d.student, frappe._dict()).setdefault(d.date, "")
+		if students_with_leave_application and d.student in students_with_leave_application.get(d.date):
+			att_map[d.student][d.date] = "Present"
+		else:
+			att_map[d.student][d.date] = d.status
 	return att_map
 
-def get_conditions(filters):
-	if not (filters.get("month") and filters.get("year")):
-		msgprint(_("Please select month and year"), raise_exception=1)
+def get_students_with_leave_application(from_date, to_date, students_list):
+	leave_applications = frappe.db.sql("""
+		select student, from_date, to_date 
+		from `tabStudent Leave Application` 
+		where 
+			mark_as_present and docstatus = 1
+			and student in %(students)s
+			and (
+				from_date between %(from_date)s and %(to_date)s
+				or to_date between %(from_date)s and %(to_date)s
+				or (%(from_date)s between from_date and to_date and %(to_date)s between from_date and to_date)
+			)
+		""", {
+			"students": students_list,
+			"from_date": from_date,
+			"to_date": to_date
+		}, as_dict=True)
+	students_with_leaves= {}
+	for application in leave_applications:
+		for date in daterange(application.from_date, application.to_date):
+			students_with_leaves.setdefault(date, []).append(application.student)
 
-	filters["month"] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
-		"Dec"].index(filters.month) + 1
+	return students_with_leaves
 
-	filters["total_days_in_month"] = monthrange(cint(filters.year), filters.month)[1]
-
-	conditions = " and month(date) = %(month)s and year(date) = %(year)s"
-
-	if filters.get("student_batch"): conditions += " and student_batch = %(student_batch)s"
-
-	return conditions, filters
+def daterange(d1, d2):
+	import datetime
+	return (d1 + datetime.timedelta(days=i) for i in range((d2 - d1).days + 1))
 
 @frappe.whitelist()
 def get_attendance_years():
 	year_list = frappe.db.sql_list("""select distinct YEAR(date) from `tabStudent Attendance` ORDER BY YEAR(date) DESC""")
 	if not year_list:
 		year_list = [getdate().year]
-
 	return "\n".join(str(year) for year in year_list)
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index fc3cb3d..7ddf45d 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -212,7 +212,7 @@
 					item_code: item.item_code,
 					warehouse: item.warehouse,
 					qty: item.qty,
-					serial_no:item.serial_no
+					serial_no: item.serial_no || ""
 				},
 				callback:function(r){
 					if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
index 1cb0fcd..e1ac06e 100644
--- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
+++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
@@ -1691,7 +1691,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-11-23 12:33:37.728117", 
+ "modified": "2016-12-24 12:33:37.728117", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Delivery Note Item", 
diff --git a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.json b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.json
index e679054..61c19f0 100644
--- a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.json
+++ b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.json
@@ -9,11 +9,13 @@
  "doctype": "DocType", 
  "document_type": "Document", 
  "editable_grid": 1, 
+ "engine": "InnoDB", 
  "fields": [
   {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "item_code", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -21,6 +23,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Item Code", 
    "length": 0, 
    "no_copy": 0, 
@@ -29,6 +32,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 1, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -40,6 +44,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "description", 
    "fieldtype": "Text Editor", 
    "hidden": 0, 
@@ -47,6 +52,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Description", 
    "length": 0, 
    "no_copy": 0, 
@@ -57,6 +63,7 @@
    "print_hide_if_no_value": 0, 
    "print_width": "300px", 
    "read_only": 1, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -68,6 +75,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "receipt_document_type", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -75,6 +83,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Receipt Document Type", 
    "length": 0, 
    "no_copy": 1, 
@@ -84,6 +93,7 @@
    "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, 
@@ -94,6 +104,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "receipt_document", 
    "fieldtype": "Dynamic Link", 
    "hidden": 0, 
@@ -101,6 +112,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Receipt Document", 
    "length": 0, 
    "no_copy": 1, 
@@ -110,6 +122,7 @@
    "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, 
@@ -120,6 +133,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "col_break2", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -127,12 +141,14 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
    "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, 
@@ -143,6 +159,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -150,6 +167,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Qty", 
    "length": 0, 
    "no_copy": 0, 
@@ -157,6 +175,7 @@
    "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, 
@@ -167,6 +186,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "rate", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -174,6 +194,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Rate", 
    "length": 0, 
    "no_copy": 0, 
@@ -182,6 +203,7 @@
    "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, 
@@ -192,6 +214,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -199,6 +222,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Amount", 
    "length": 0, 
    "no_copy": 0, 
@@ -209,6 +233,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 1, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -219,6 +244,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "applicable_charges", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -226,6 +252,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Applicable Charges", 
    "length": 0, 
    "no_copy": 0, 
@@ -233,7 +260,8 @@
    "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, 
    "search_index": 0, 
@@ -244,6 +272,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "purchase_receipt_item", 
    "fieldtype": "Data", 
    "hidden": 1, 
@@ -251,6 +280,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Purchase Receipt Item", 
    "length": 0, 
    "no_copy": 1, 
@@ -258,6 +288,7 @@
    "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, 
@@ -275,7 +306,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-07-11 03:28:01.757912", 
+ "modified": "2016-12-20 04:50:19.785273", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Landed Cost Item", 
diff --git a/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.json b/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.json
index b1f5a8c..dbc6a88 100644
--- a/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.json
+++ b/erpnext/stock/doctype/landed_cost_taxes_and_charges/landed_cost_taxes_and_charges.json
@@ -9,11 +9,13 @@
  "doctype": "DocType", 
  "document_type": "", 
  "editable_grid": 1, 
+ "engine": "InnoDB", 
  "fields": [
   {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "description", 
    "fieldtype": "Text Editor", 
    "hidden": 0, 
@@ -21,6 +23,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Description", 
    "length": 0, 
    "no_copy": 0, 
@@ -28,6 +31,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -38,6 +42,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "col_break3", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -45,12 +50,14 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
    "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, 
@@ -62,6 +69,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -69,6 +77,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Amount", 
    "length": 0, 
    "no_copy": 0, 
@@ -77,6 +86,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -94,7 +104,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-07-11 03:28:01.958276", 
+ "modified": "2016-12-20 05:44:54.700163", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Landed Cost Taxes and Charges", 
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js
index 525853b..b97378f 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js
@@ -32,7 +32,7 @@
 
 	},
 
-	refresh: function() {
+	refresh: function(frm) {
 		var help_content = [
 			'<br><br>',
 			'<table class="table table-bordered" style="background-color: #f9f9f9;">',
@@ -70,12 +70,15 @@
 		} else {
 			return this.frm.call({
 				doc: me.frm.doc,
-				method: "get_items_from_purchase_receipts"
+				method: "get_items_from_purchase_receipts",
+				callback: function(r, rt) {
+					me.set_applicable_charges_for_item();
+				}
 			});
 		}
 	},
 
-	amount: function() {
+	amount: function(frm) {
 		this.set_total_taxes_and_charges();
 		this.set_applicable_charges_for_item();
 	},
@@ -90,17 +93,23 @@
 
 	set_applicable_charges_for_item: function() {
 		var me = this;
+
 		if(this.frm.doc.taxes.length) {
+			
 			var total_item_cost = 0.0;
+			var based_on = this.frm.doc.distribute_charges_based_on.toLowerCase();
 			$.each(this.frm.doc.items || [], function(i, d) {
-				total_item_cost += flt(d.amount)
+				total_item_cost += flt(d[based_on])
 			});
 
 			$.each(this.frm.doc.items || [], function(i, item) {
-				item.applicable_charges = flt(item.amount) *  flt(me.frm.doc.total_taxes_and_charges) / flt(total_item_cost)
+				item.applicable_charges = flt(item[based_on]) * flt(me.frm.doc.total_taxes_and_charges) / flt(total_item_cost)			
 			});
 			refresh_field("items");
 		}
+	},
+	distribute_charges_based_on: function (frm) {
+		this.set_applicable_charges_for_item();
 	}
 
 });
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json
index 227541f..db6e402 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json
@@ -10,6 +10,7 @@
  "doctype": "DocType", 
  "document_type": "Document", 
  "editable_grid": 0, 
+ "engine": "InnoDB", 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -101,6 +102,34 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "purchase_receipt_items", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Purchase Receipt Items", 
+   "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": "get_items_from_purchase_receipts", 
    "fieldtype": "Button", 
    "hidden": 0, 
@@ -156,6 +185,35 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "sec_break1", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Additional Charges", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "", 
+   "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": "taxes", 
    "fieldtype": "Table", 
    "hidden": 0, 
@@ -184,7 +242,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "sec_break1", 
+   "fieldname": "section_break_9", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
@@ -194,7 +252,6 @@
    "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
-   "options": "Simple", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -240,34 +297,6 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "amended_from", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Amended From", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Landed Cost Voucher", 
-   "permlevel": 0, 
-   "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_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
    "fieldname": "col_break1", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -295,7 +324,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "default": "Amount", 
+   "default": "", 
    "fieldname": "distribute_charges_based_on", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -325,6 +354,34 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "amended_from", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Amended From", 
+   "length": 0, 
+   "no_copy": 1, 
+   "options": "Landed Cost Voucher", 
+   "permlevel": 0, 
+   "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_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "sec_break2", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -378,7 +435,7 @@
  ], 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
- "icon": "fa fa-usd", 
+ "icon": "icon-usd", 
  "idx": 0, 
  "image_view": 0, 
  "in_create": 0, 
@@ -387,7 +444,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-11-07 05:09:46.981120", 
+ "modified": "2016-12-21 01:40:13.959409", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Landed Cost Voucher", 
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
index cdf7263..aacf02c 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
@@ -29,9 +29,6 @@
 				item.receipt_document = pr.receipt_document
 				item.purchase_receipt_item = d.name
 
-		if self.get("taxes"):
-			self.set_applicable_charges_for_item()
-
 	def validate(self):
 		self.check_mandatory()
 		self.validate_purchase_receipts()
@@ -39,15 +36,13 @@
 		if not self.get("items"):
 			self.get_items_from_purchase_receipts()
 		else:
-			self.set_applicable_charges_for_item()
+			self.validate_applicable_charges_for_item()
 
 	def check_mandatory(self):
 		if not self.get("purchase_receipts"):
 			frappe.throw(_("Please enter Receipt Document"))
 
-		if not self.get("taxes"):
-			frappe.throw(_("Please enter Taxes and Charges"))
-
+		
 	def validate_purchase_receipts(self):
 		receipt_documents = []
 		
@@ -67,15 +62,18 @@
 	def set_total_taxes_and_charges(self):
 		self.total_taxes_and_charges = sum([flt(d.amount) for d in self.get("taxes")])
 
-	def set_applicable_charges_for_item(self):
+	def validate_applicable_charges_for_item(self):
 		based_on = self.distribute_charges_based_on.lower()
+		
 		total = sum([flt(d.get(based_on)) for d in self.get("items")])
-
+		
 		if not total:
-			frappe.throw(_("Total {0} for all items is zero, may you should change 'Distribute Charges Based On'").format(based_on))
+			frappe.throw(_("Total {0} for all items is zero, may be you should change 'Distribute Charges Based On'").format(based_on))
+		
+		if self.total_taxes_and_charges != sum([flt(d.applicable_charges) for d in self.get("items")]):
+			frappe.throw(_("Total Applicable Charges in Purchase Receipt Items table must be same as Total Taxes and Charges"))
 
-		for item in self.get("items"):
-			item.applicable_charges = flt(item.get(based_on)) *  flt(self.total_taxes_and_charges) / flt(total)
+
 
 	def on_submit(self):
 		self.update_landed_cost()
diff --git a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
index c58607f..409770e 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
+++ b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
@@ -5,6 +5,7 @@
 from __future__ import unicode_literals
 import unittest
 import frappe
+from frappe.utils import flt
 from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
 	import set_perpetual_inventory, get_gl_entries, test_records as pr_test_records
 from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
@@ -23,7 +24,7 @@
 			},
 			fieldname=["qty_after_transaction", "stock_value"], as_dict=1)
 
-		self.submit_landed_cost_voucher("Purchase Receipt", pr.name)
+		submit_landed_cost_voucher("Purchase Receipt", pr.name)
 
 		pr_lc_value = frappe.db.get_value("Purchase Receipt Item", {"parent": pr.name}, "landed_cost_voucher_amount")
 		self.assertEquals(pr_lc_value, 25.0)
@@ -75,7 +76,7 @@
 			},
 			fieldname=["qty_after_transaction", "stock_value"], as_dict=1)
 
-		self.submit_landed_cost_voucher("Purchase Invoice", pi.name)
+		submit_landed_cost_voucher("Purchase Invoice", pi.name)
 		
 		pi_lc_value = frappe.db.get_value("Purchase Invoice Item", {"parent": pi.name}, 
 			"landed_cost_voucher_amount")
@@ -121,7 +122,7 @@
 
 		serial_no_rate = frappe.db.get_value("Serial No", "SN001", "purchase_rate")
 
-		self.submit_landed_cost_voucher("Purchase Receipt", pr.name)
+		submit_landed_cost_voucher("Purchase Receipt", pr.name)
 
 		serial_no = frappe.db.get_value("Serial No", "SN001",
 			["warehouse", "purchase_rate"], as_dict=1)
@@ -131,27 +132,37 @@
 
 		set_perpetual_inventory(0)
 
-	def submit_landed_cost_voucher(self, receipt_document_type, receipt_document):
-		ref_doc = frappe.get_doc(receipt_document_type, receipt_document)
-		
-		lcv = frappe.new_doc("Landed Cost Voucher")
-		lcv.company = "_Test Company"
-		lcv.set("purchase_receipts", [{
-			"receipt_document_type": receipt_document_type,
-			"receipt_document": receipt_document,
-			"supplier": ref_doc.supplier,
-			"posting_date": ref_doc.posting_date,
-			"grand_total": ref_doc.base_grand_total
-		}])
-		
-		lcv.set("taxes", [{
-			"description": "Insurance Charges",
-			"account": "_Test Account Insurance Charges - _TC",
-			"amount": 50
-		}])
+def submit_landed_cost_voucher(receipt_document_type, receipt_document):
+	ref_doc = frappe.get_doc(receipt_document_type, receipt_document)
+	
+	lcv = frappe.new_doc("Landed Cost Voucher")
+	lcv.company = "_Test Company"
+	lcv.distribute_charges_based_on = 'Amount'
+	
+	lcv.set("purchase_receipts", [{
+		"receipt_document_type": receipt_document_type,
+		"receipt_document": receipt_document,
+		"supplier": ref_doc.supplier,
+		"posting_date": ref_doc.posting_date,
+		"grand_total": ref_doc.base_grand_total
+	}])
+	
+	lcv.set("taxes", [{
+		"description": "Insurance Charges",
+		"account": "_Test Account Insurance Charges - _TC",
+		"amount": 50
+	}])
 
-		lcv.insert()
-		lcv.submit()
-
+	lcv.insert()
+	
+	distribute_landed_cost_on_items(lcv)
+	
+	lcv.submit()
+		
+def distribute_landed_cost_on_items(lcv):
+	based_on = lcv.distribute_charges_based_on.lower()
+	total = sum([flt(d.get(based_on)) for d in lcv.get("items")])
+	for item in lcv.get("items"):
+		item.applicable_charges = flt(item.get(based_on)) * flt(lcv.total_taxes_and_charges) / flt(total)
 
 test_records = frappe.get_test_records('Landed Cost Voucher')
diff --git a/erpnext/stock/doctype/material_request/material_request_list.js b/erpnext/stock/doctype/material_request/material_request_list.js
index eb14930..b6ceeac 100644
--- a/erpnext/stock/doctype/material_request/material_request_list.js
+++ b/erpnext/stock/doctype/material_request/material_request_list.js
@@ -3,10 +3,10 @@
 	get_indicator: function(doc) {
 		if(doc.status=="Stopped") {
 			return [__("Stopped"), "red", "status,=,Stopped"];
-		} else if(doc.docstatus==1 && flt(doc.per_ordered, 2) == 0.00) {
+		} else if(doc.docstatus==1 && flt(doc.per_ordered, 2) == 0) {
 			return [__("Pending"), "orange", "per_ordered,=,0"];
-		} else if(doc.docstatus==1 && flt(doc.per_ordered, 2) < 100) {
-			return [__("Partially Ordered"), "orange", "per_ordered,<,100"];
+		}  else if(doc.docstatus==1 && flt(doc.per_ordered, 2) < 100) {
+			return [__("Partially ordred"), "yellow", "per_ordered,<,100"];
 		} else if(doc.docstatus==1 && flt(doc.per_ordered, 2) == 100) {
 			if (doc.material_request_type == "Purchase") {
 				return [__("Ordered"), "green", "per_ordered,=,100"];
diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json
index 6501682..4801d40 100644
--- a/erpnext/stock/doctype/stock_settings/stock_settings.json
+++ b/erpnext/stock/doctype/stock_settings/stock_settings.json
@@ -8,11 +8,13 @@
  "description": "Settings", 
  "docstatus": 0, 
  "doctype": "DocType", 
+ "editable_grid": 0, 
  "fields": [
   {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "Item Code", 
    "fieldname": "item_naming_by", 
    "fieldtype": "Select", 
@@ -21,6 +23,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Item Naming By", 
    "length": 0, 
    "no_copy": 0, 
@@ -29,6 +32,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, 
@@ -39,6 +43,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "description": "", 
    "fieldname": "item_group", 
    "fieldtype": "Link", 
@@ -47,6 +52,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Default Item Group", 
    "length": 0, 
    "no_copy": 0, 
@@ -55,6 +61,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 +72,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "stock_uom", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -72,6 +80,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Default Stock UOM", 
    "length": 0, 
    "no_copy": 0, 
@@ -80,6 +89,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, 
@@ -90,6 +100,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "default_warehouse", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -97,6 +108,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Default Warehouse", 
    "length": 0, 
    "no_copy": 0, 
@@ -106,6 +118,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, 
@@ -116,6 +129,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "column_break_4", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -123,12 +137,14 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
    "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, 
@@ -139,6 +155,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "valuation_method", 
    "fieldtype": "Select", 
    "hidden": 0, 
@@ -146,6 +163,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Default Valuation Method", 
    "length": 0, 
    "no_copy": 0, 
@@ -154,6 +172,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, 
@@ -164,6 +183,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units.", 
    "fieldname": "tolerance", 
    "fieldtype": "Float", 
@@ -172,13 +192,15 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "label": "Allowance Percent", 
+   "in_standard_filter": 0, 
+   "label": "Limit Percent", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
    "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, 
@@ -189,6 +211,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "1", 
    "fieldname": "show_barcode_field", 
    "fieldtype": "Check", 
@@ -197,6 +220,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Show Barcode Field", 
    "length": 0, 
    "no_copy": 0, 
@@ -205,6 +229,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, 
@@ -215,6 +240,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "section_break_7", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -222,6 +248,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -229,6 +256,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, 
@@ -239,6 +267,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "auto_insert_price_list_rate_if_missing", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -246,6 +275,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Auto insert Price List rate if missing", 
    "length": 0, 
    "no_copy": 0, 
@@ -254,6 +284,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, 
@@ -264,6 +295,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "allow_negative_stock", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -271,6 +303,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Allow Negative Stock", 
    "length": 0, 
    "no_copy": 0, 
@@ -278,6 +311,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, 
@@ -288,6 +322,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "column_break_10", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -295,6 +330,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -302,6 +338,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, 
@@ -312,6 +349,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "default": "1", 
    "fieldname": "automatically_set_serial_nos_based_on_fifo", 
    "fieldtype": "Check", 
@@ -320,6 +358,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Automatically Set Serial Nos based on FIFO", 
    "length": 0, 
    "no_copy": 0, 
@@ -328,6 +367,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, 
@@ -338,6 +378,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "auto_material_request", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -345,6 +386,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Auto Material Request", 
    "length": 0, 
    "no_copy": 0, 
@@ -352,6 +394,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, 
@@ -362,6 +405,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "auto_indent", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -369,6 +413,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Raise Material Request when stock reaches re-order level", 
    "length": 0, 
    "no_copy": 0, 
@@ -376,6 +421,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, 
@@ -386,6 +432,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "reorder_email_notify", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -393,6 +440,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Notify by Email on creation of automatic Material Request", 
    "length": 0, 
    "no_copy": 0, 
@@ -400,6 +448,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, 
@@ -410,6 +459,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "freeze_stock_entries", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -417,6 +467,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Freeze Stock Entries", 
    "length": 0, 
    "no_copy": 0, 
@@ -424,6 +475,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, 
@@ -434,6 +486,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "stock_frozen_upto", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -441,6 +494,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Stock Frozen Upto", 
    "length": 0, 
    "no_copy": 0, 
@@ -448,6 +502,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, 
@@ -458,6 +513,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "stock_frozen_upto_days", 
    "fieldtype": "Int", 
    "hidden": 0, 
@@ -465,6 +521,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Freeze Stocks Older Than [Days]", 
    "length": 0, 
    "no_copy": 0, 
@@ -472,6 +529,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, 
@@ -482,6 +540,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "stock_auth_role", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -489,6 +548,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Role Allowed to edit frozen stock", 
    "length": 0, 
    "no_copy": 0, 
@@ -497,6 +557,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, 
@@ -506,15 +567,16 @@
  ], 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
- "icon": "fa fa-cog", 
+ "icon": "icon-cog", 
  "idx": 1, 
+ "image_view": 0, 
  "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 1, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-05-12 12:28:29.374452", 
+ "modified": "2016-12-16 02:18:58.187847", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Stock Settings", 
@@ -530,6 +592,7 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
+   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 7bcad08..0ed6952 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -384,7 +384,7 @@
 	return {'serial_no': serial_no}
 	
 @frappe.whitelist()
-def get_bin_details_and_serial_nos(item_code, warehouse, qty, serial_no):
+def get_bin_details_and_serial_nos(item_code, warehouse, qty=None, serial_no=None):
 	bin_details_and_serial_nos = {}
 	bin_details_and_serial_nos.update(get_bin_details(item_code, warehouse))
 	bin_details_and_serial_nos.update(get_serial_no_details(item_code, warehouse, qty, serial_no))