Merge pull request #6772 from frappe/bcornwellmott-patch-3

[fix] Change communication to Linked
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 4c87187..58b7955 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.1.3'
+__version__ = '7.1.4'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 083ba6f..145ed81 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -763,7 +763,8 @@
 	return {
 		"account": account,
 		"balance": account_balance,
-		"party_balance": party_balance
+		"party_balance": party_balance,
+		"account_currency": frappe.db.get_value("Account", account, "account_currency")
 	}
 
 @frappe.whitelist()
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index f43a436..4c13fe3 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -392,7 +392,7 @@
 				if(index < 30){
 					$(frappe.render_template("pos_item", {
 						item_code: obj.name,
-						item_price: format_currency(obj.price_list_rate, obj.currency),
+						item_price: format_currency(obj.price_list_rate, me.frm.doc.currency),
 						item_name: obj.name===obj.item_name ? "" : obj.item_name,
 						item_image: obj.image ? "url('" + obj.image + "')" : null,
 						color: frappe.get_palette(obj.item_name),
diff --git a/erpnext/docs/assets/img/articles/withhold-1.png b/erpnext/docs/assets/img/articles/withhold-1.png
new file mode 100644
index 0000000..89b63a0
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/withhold-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/withhold-2.gif b/erpnext/docs/assets/img/articles/withhold-2.gif
new file mode 100644
index 0000000..87a92c1
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/withhold-2.gif
Binary files differ
diff --git a/erpnext/docs/user/manual/en/accounts/articles/adjust-withhold-amount-payment-entry.md b/erpnext/docs/user/manual/en/accounts/articles/adjust-withhold-amount-payment-entry.md
new file mode 100644
index 0000000..d469b28
--- /dev/null
+++ b/erpnext/docs/user/manual/en/accounts/articles/adjust-withhold-amount-payment-entry.md
@@ -0,0 +1,37 @@
+#Adjust Withhold Amount in the Payment Entry
+
+###Question
+
+Let's assume that outstanding against a Sales Invoice is 20,000. When client makes payment, they will only pay 19,600. Rest 400 will be booked under Withhold account. How to manage this scenario in the Payment Entry.
+
+###Answer
+
+In the Payment Entry, you can mention Withhold Account in the Deductions or Loss table. Detailed steps below.
+
+####Step 1: Setup Withhold Account
+
+Create a Withhold Account in your Chart of Accounts master.
+
+`Accounts > Chart of Accounts'
+
+####Step 2: Payment Entry
+
+To create Payment Entry, go to unpaid Sales Invoice and create click on Make Payment button.
+
+#####Step 2.1: Enter Payment Amount
+
+Enter Payment Amount as 19,600.
+
+<img alt="Sales Invoice Payment Amount" class="screenshot" src="{{docs_base_url}}/assets/img/articles/withhold-1.png">
+
+#####Step 2.2: Allocate Against Sales Invoice
+
+Against Sales Invoice, allocate 20,000 (explained in GIF below).
+
+#####Step 2.3: Add Deduction/Loss Account
+
+You can notice that there is a difference of 400 in the Payment Amount and the Amount Allocated against Sales Invoice. You can book this difference account under Withhold Account.
+
+<img alt="Deduction/Loss Account" class="screenshot" src="{{docs_base_url}}/assets/img/articles/withhold-2.gif">
+
+ Following same steps, you can also manage difference availed due to Currency Exchange Gain/Loss.
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/accounts/articles/index.txt b/erpnext/docs/user/manual/en/accounts/articles/index.txt
index c2fbf70..77474bd 100644
--- a/erpnext/docs/user/manual/en/accounts/articles/index.txt
+++ b/erpnext/docs/user/manual/en/accounts/articles/index.txt
@@ -11,4 +11,5 @@
 update-stock-option-in-sales-invoice
 what-is-the-differences-of-total-and-valuation-in-tax-and-charges
 withdrawing-salary-from-owners-equity-account
+adjust-withhold-amount-payment-entry
 c-form
\ No newline at end of file
diff --git a/erpnext/docs/user/videos/index.md b/erpnext/docs/user/videos/index.md
index 071dedb..9a82db5 100644
--- a/erpnext/docs/user/videos/index.md
+++ b/erpnext/docs/user/videos/index.md
@@ -18,7 +18,7 @@
 ---
 
 <h3>
-	<a class="no-decoration" href="https://conf.erpnext.com/2014/videos">Conference Vidoes</a>
+	<a class="no-decoration" href="https://conf.erpnext.com/2014/videos">Conference Videos</a>
 </h3>
 
 <div class="row">
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index d694ef4..0c75d15 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -342,4 +342,4 @@
 erpnext.patches.v7_1.set_prefered_contact_email
 execute:frappe.db.sql("update `tabSingles` set value = 1 where field = 'unlink_payment_on_cancellation_of_invoice' and doctype = 'Accounts Settings'")
 execute:frappe.db.sql("update `tabStock Entry` set total_amount = null where purpose in('Repack', 'Manufacture')")
-erpnext.patches.v7_1.repost_gle_for_pi_with_update_stock
\ No newline at end of file
+erpnext.patches.v7_0.repost_gle_for_pi_with_update_stock #2016-11-01
\ No newline at end of file
diff --git a/erpnext/patches/v7_1/repost_gle_for_pi_with_update_stock.py b/erpnext/patches/v7_0/repost_gle_for_pi_with_update_stock.py
similarity index 74%
rename from erpnext/patches/v7_1/repost_gle_for_pi_with_update_stock.py
rename to erpnext/patches/v7_0/repost_gle_for_pi_with_update_stock.py
index 2355d53..2883a8a 100644
--- a/erpnext/patches/v7_1/repost_gle_for_pi_with_update_stock.py
+++ b/erpnext/patches/v7_0/repost_gle_for_pi_with_update_stock.py
@@ -11,6 +11,10 @@
 
 	for pi in frappe.db.sql("""select name from `tabPurchase Invoice` 
 		where update_stock=1 and docstatus=1  order by posting_date asc""", as_dict=1):
+		
+			frappe.db.sql("""delete from `tabGL Entry` 
+				where voucher_type = 'Purchase Invoice' and voucher_no = %s""", pi.name)
+				
 			pi_doc = frappe.get_doc("Purchase Invoice", pi.name)
-			pi_doc.make_gl_entries()
+			pi_doc.make_gl_entries(repost_future_gle=False)
 			frappe.db.commit()
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index a60e945..1a3c26c 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -31,7 +31,7 @@
 			item.update(get_bin_details(item.item_code, item.s_warehouse))
 
 	def validate(self):
-		self.pro_doc = None
+		self.pro_doc = frappe._dict()
 		if self.production_order:
 			self.pro_doc = frappe.get_doc('Production Order', self.production_order)
 
@@ -582,7 +582,7 @@
 
 	def set_production_order_details(self):
 		if not getattr(self, "pro_doc", None):
-			self.pro_doc = None
+			self.pro_doc = frappe._dict()
 
 		if self.production_order:
 			# common validations