Merge pull request #5901 from bcornwellmott/fix_employee_lookup

Fix Timesheet employee query to show names
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 0a6655d..b592739 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.0.7'
+__version__ = '7.0.10'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 28978cd..6c04cf5 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -251,8 +251,8 @@
 				self.unallocated_amount = party_amount - self.total_allocated_amount
 				
 	def set_difference_amount(self):
-		base_unallocated_amount = flt(self.unallocated_amount) * \
-			(self.source_exchange_rate if self.payment_type=="Receive" else self.target_exchange_rate)
+		base_unallocated_amount = flt(self.unallocated_amount) * (flt(self.source_exchange_rate) 
+			if self.payment_type=="Receive" else flt(self.target_exchange_rate))
 			
 		base_party_amount = flt(self.base_total_allocated_amount) + flt(base_unallocated_amount)
 		
@@ -267,6 +267,8 @@
 			if d.amount:
 				self.difference_amount -= flt(d.amount)
 				
+		self.difference_amount = flt(self.difference_amount, self.precision("difference_amount"))
+				
 	def clear_unallocated_reference_document_rows(self):
 		self.set("references", self.get("references", {"allocated_amount": ["not in", [0, None, ""]]}))
 
@@ -672,7 +674,7 @@
 
 	pe.setup_party_account_field()
 	pe.set_missing_values()
-	if bank:
+	if party_account and bank:
 		pe.set_exchange_rate()
 		pe.set_amounts()
 	return pe
\ No newline at end of file
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 1806d93..2e76516 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -87,7 +87,7 @@
 
 	refresh: function(doc) {
 		this.frm.toggle_display("supplier_name",
-			(this.supplier_name && this.frm.doc.supplier_name!==this.frm.doc.supplier));
+			(this.frm.doc.supplier_name && this.frm.doc.supplier_name!==this.frm.doc.supplier));
 
 		if(this.frm.docstatus==0 &&
 			(this.frm.doctype==="Purchase Order" || this.frm.doctype==="Material Request")) {
diff --git a/erpnext/crm/doctype/opportunity/opportunity.json b/erpnext/crm/doctype/opportunity/opportunity.json
index 2a0820b..ee625b4 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.json
+++ b/erpnext/crm/doctype/opportunity/opportunity.json
@@ -10,6 +10,7 @@
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "Document", 
+ "editable_grid": 1, 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -266,7 +267,7 @@
    "no_copy": 1, 
    "oldfieldname": "status", 
    "oldfieldtype": "Select", 
-   "options": "Open\nQuotation\nLost\nReplied\nClosed", 
+   "options": "Open\nQuotation\nConverted\nLost\nReplied\nClosed", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -1001,7 +1002,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-06-14 15:50:55.080217", 
+ "modified": "2016-07-28 15:58:06.614493", 
  "modified_by": "Administrator", 
  "module": "CRM", 
  "name": "Opportunity", 
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 6971e0d..d7c156d 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -303,4 +303,4 @@
 erpnext.patches.v7_0.remove_administrator_role_in_doctypes
 erpnext.patches.v7_0.rename_fee_amount_to_fee_component
 erpnext.patches.v7_0.calculate_total_costing_amount
-erpnext.patches.v7_0.fix_nonwarehouse_ledger_gl_entries_for_transactions
+erpnext.patches.v7_0.fix_nonwarehouse_ledger_gl_entries_for_transactions
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
index ba1d067..174bb11 100644
--- a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
+++ b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
@@ -15,6 +15,8 @@
 		and (warehouse is null or warehouse = '')""")
 	if warehouses:
 		warehouses = set_warehouse_for_stock_account(warehouses)
+		if not warehouses:
+			return
 
 		stock_vouchers = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no
 			from `tabStock Ledger Entry` sle
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index ece8284..4081ca2 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -33,13 +33,13 @@
 
 	setup_serial_no: function() {
 		var grid_row = cur_frm.open_grid_row();
-		if(!grid_row || !grid_row.fields_dict.serial_no ||
-			grid_row.fields_dict.serial_no.get_status()!=="Write") return;
+		if(!grid_row || !grid_row.grid_form.fields_dict.serial_no ||
+			grid_row.grid_form.fields_dict.serial_no.get_status()!=="Write") return;
 
 		var $btn = $('<button class="btn btn-sm btn-default">'+__("Add Serial No")+'</button>')
 			.appendTo($("<div>")
 				.css({"margin-bottom": "10px", "margin-top": "10px"})
-				.appendTo(grid_row.fields_dict.serial_no.$wrapper));
+				.appendTo(grid_row.grid_form.fields_dict.serial_no.$wrapper));
 
 		$btn.on("click", function() {
 			var d = new frappe.ui.Dialog({
@@ -69,7 +69,7 @@
 				var serial_no = d.get_value("serial_no");
 				if(serial_no) {
 					var val = (grid_row.doc.serial_no || "").split("\n").concat([serial_no]).join("\n");
-					grid_row.fields_dict.serial_no.set_model_value(val.trim());
+					grid_row.grid_form.fields_dict.serial_no.set_model_value(val.trim());
 				}
 				d.hide();
 				return false;
@@ -190,4 +190,4 @@
 			});
 		});
 	}
-});
\ No newline at end of file
+});
diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js
index f5496ed..a3f3550 100644
--- a/erpnext/public/js/utils/party.js
+++ b/erpnext/public/js/utils/party.js
@@ -45,6 +45,7 @@
 				frm.set_value(r.message);
 				frm.updating_party_details = false;
 				if(callback) callback();
+				frm.refresh();
 			}
 		}
 	});
diff --git a/erpnext/schools/doctype/fees/fees.json b/erpnext/schools/doctype/fees/fees.json
index 75e3315..ce911ad 100644
--- a/erpnext/schools/doctype/fees/fees.json
+++ b/erpnext/schools/doctype/fees/fees.json
@@ -394,6 +394,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "default": "0", 
    "fieldname": "total_amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -419,7 +420,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "default": "", 
+   "default": "0", 
    "fieldname": "paid_amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -445,6 +446,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "default": "0", 
    "fieldname": "outstanding_amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -478,7 +480,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-25 08:44:33.595812", 
+ "modified": "2016-07-27 03:52:28.509757", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Fees", 
diff --git a/erpnext/schools/doctype/fees/fees.py b/erpnext/schools/doctype/fees/fees.py
index 0f2db50..d2540f7 100644
--- a/erpnext/schools/doctype/fees/fees.py
+++ b/erpnext/schools/doctype/fees/fees.py
@@ -14,8 +14,9 @@
 	def calculate_total(self):
 		"""Calculates total amount."""
 		self.total_amount = 0
-		for d in self.amount:
+		for d in self.components:
 			self.total_amount += d.amount
+		self.outstanding_amount = self.total_amount
 
 def get_fee_list(doctype, txt, filters, limit_start, limit_page_length=20):
 	user = frappe.session.user
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 03f2ee1..a980ed0 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -250,7 +250,7 @@
 
 					self.valuation_rate = new_stock_value / new_stock_qty
 				else:
-					self.valuation_rate = self.outgoing_rate
+					self.valuation_rate = sle.outgoing_rate
 
 		else:
 			if flt(self.qty_after_transaction) >= 0 and sle.outgoing_rate: