[patch] move supplier_address to address_display and set supplier_address in SE

This commit is contained in:
mbauskar 2017-04-13 16:16:15 +05:30
parent 1b32d913a2
commit 3ddfce4f17
3 changed files with 24 additions and 2 deletions

View File

@ -384,3 +384,4 @@ 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
erpnext.patches.v8_0.update_supplier_address_in_stock_entry

View File

@ -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)

View File

@ -230,7 +230,6 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
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)