Merge branch 'develop'
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 5b6f359..881087a 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '8.0.6'
+__version__ = '8.0.7'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index bec57f4..0355c26 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -404,11 +404,14 @@
 			self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance"))
 
 			if self.doc.party_account_currency == self.doc.currency:
-				invoice_total = self.doc.grand_total
-			else:
-				invoice_total = flt(self.doc.grand_total * self.doc.conversion_rate,
+				invoice_total = flt(self.doc.grand_total - flt(self.doc.write_off_amount), 
 					self.doc.precision("grand_total"))
-
+			else:
+				base_write_off_amount = flt(flt(self.doc.write_off_amount) * self.doc.conversion_rate, 
+					self.doc.precision("base_write_off_amount"))
+				invoice_total = flt(self.doc.grand_total * self.doc.conversion_rate, 
+					self.doc.precision("grand_total")) - base_write_off_amount
+				
 			if invoice_total > 0 and self.doc.total_advance > invoice_total:
 				frappe.throw(_("Advance amount cannot be greater than {0} {1}")
 					.format(self.doc.party_account_currency, invoice_total))
diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py
index c1a8bed..3675f0f 100644
--- a/erpnext/demo/setup/setup_data.py
+++ b/erpnext/demo/setup/setup_data.py
@@ -64,8 +64,11 @@
 		})
 
 		company = erpnext.get_default_company()
-		company.db_set('default_payroll_payable_account',
-			frappe.db.get_value('Account', dict(account_name='Payroll Payable')))
+
+		if company:
+			company_doc = frappe.get_doc("Company", company)
+			company_doc.db_set('default_payroll_payable_account',
+				frappe.db.get_value('Account', dict(account_name='Payroll Payable')))
 
 def setup_demo_page():
 	# home page should always be "start"
diff --git a/erpnext/selling/doctype/customer/customer_list.js b/erpnext/selling/doctype/customer/customer_list.js
index 09c3e93..38fc9ad 100644
--- a/erpnext/selling/doctype/customer/customer_list.js
+++ b/erpnext/selling/doctype/customer/customer_list.js
@@ -1,3 +1,3 @@
 frappe.listview_settings['Customer'] = {
-	add_fields: ["customer_name", "territory", "customer_group", "customer_type"],
+	add_fields: ["customer_name", "territory", "customer_group", "customer_type", "image"],
 };
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 26298bc..c09255d 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -79,7 +79,7 @@
 		if not frappe.local.flags.ignore_chart_of_accounts:
 			self.set_default_accounts()
 			if self.default_cash_account:
-				self.mode_of_payment()
+				self.set_mode_of_payment_account()
 
 		if self.default_currency:
 			frappe.db.set_value("Currency", self.default_currency, "enabled", 1)
@@ -166,7 +166,7 @@
 		if account:
 			self.db_set(fieldname, account)
 
-	def mode_of_payment(self):
+	def set_mode_of_payment_account(self):
 		cash = frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name')
 		if cash and not frappe.db.get_value('Mode of Payment Account', {'company': self.name}):
 			mode_of_payment = frappe.get_doc('Mode of Payment', cash)