[patch] move supplier_address to address_display and set supplier_address in SE
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 5bf0f3f..b015e0a 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -383,4 +383,5 @@
erpnext.patches.v8_0.repost_reserved_qty_for_multiple_sales_uom
erpnext.patches.v8_0.addresses_linked_to_lead
execute:frappe.delete_doc('DocType', 'Purchase Common')
-erpnext.patches.v8_0.update_stock_qty_value_in_purchase_invoice
\ No newline at end of file
+erpnext.patches.v8_0.update_stock_qty_value_in_purchase_invoice
+erpnext.patches.v8_0.update_supplier_address_in_stock_entry
\ No newline at end of file
diff --git a/erpnext/patches/v8_0/update_supplier_address_in_stock_entry.py b/erpnext/patches/v8_0/update_supplier_address_in_stock_entry.py
new file mode 100644
index 0000000..e4032a2
--- /dev/null
+++ b/erpnext/patches/v8_0/update_supplier_address_in_stock_entry.py
@@ -0,0 +1,22 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ # copy supplier_address to address_display, and set supplier_address to blank
+
+ stock_entries = frappe.db.sql(""" select name, purchase_order, supplier_address from `tabStock Entry`
+ where ifnull(supplier_address, '') <> ''""", as_dict=True)
+
+ frappe.reload_doc('stock', 'doctype', 'stock_entry')
+
+ for stock_entry in stock_entries:
+ # move supplier address to address_display, and fetch the supplier address from purchase order
+
+ se = frappe.get_doc("Stock Entry", stock_entry.get("name"))
+ se.address_display = stock_entry.get("supplier_address")
+ se.supplier_address = frappe.db.get_value("Purchase Order", stock_entry.get("purchase_order"),"supplier_address") or None
+
+ se.save(ignore_permissions=True)
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 3777f89..4e381ea 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -230,7 +230,6 @@
function(doc) { return (doc.qty<=doc.actual_qty) ? "green" : "orange" })
this.frm.add_fetch("purchase_order", "supplier", "supplier");
- this.frm.add_fetch("supplier", "supplier_name", "supplier_name");
frappe.dynamic_link = { doc: this.frm.doc, fieldname: 'supplier', doctype: 'Supplier' }
this.frm.set_query("supplier_address", erpnext.queries.address_query)