Merge pull request #8430 from mbauskar/stock-entry-supplier-address

[minor] fetch supplier address, address_display on supplier trigger
This commit is contained in:
Nabin Hait 2017-04-13 18:45:09 +05:30 committed by GitHub
commit 3a2727c9eb
5 changed files with 68 additions and 5 deletions

View File

@ -340,7 +340,8 @@ def make_stock_entry(purchase_order, item_code):
stock_entry.purchase_order = purchase_order.name
stock_entry.supplier = purchase_order.supplier
stock_entry.supplier_name = purchase_order.supplier_name
stock_entry.supplier_address = purchase_order.address_display
stock_entry.supplier_address = purchase_order.supplier_address
stock_entry.address_display = purchase_order.address_display
stock_entry.company = purchase_order.company
stock_entry.from_bom = 1
po_item = [d for d in purchase_order.items if d.item_code == item_code][0]

View File

@ -383,4 +383,5 @@ erpnext.patches.v8_0.manufacturer_childtable_migrate
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_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.db_update()

View File

@ -229,6 +229,10 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
this.frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.actual_qty) ? "green" : "orange" })
this.frm.add_fetch("purchase_order", "supplier", "supplier");
frappe.dynamic_link = { doc: this.frm.doc, fieldname: 'supplier', doctype: 'Supplier' }
this.frm.set_query("supplier_address", erpnext.queries.address_query)
},
onload_post_render: function() {
@ -509,7 +513,8 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
} else {
doc.customer = doc.customer_name = doc.customer_address =
doc.delivery_note_no = doc.sales_invoice_no = doc.supplier =
doc.supplier_name = doc.supplier_address = doc.purchase_receipt_no = null;
doc.supplier_name = doc.supplier_address = doc.purchase_receipt_no =
doc.address_display = null;
}
if(doc.purpose == "Material Receipt") {
this.frm.set_value("from_bom", 0);
@ -520,5 +525,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
doc.purpose!='Material Issue');
this.frm.fields_dict["items"].grid.set_column_disp("additional_cost", doc.purpose!='Material Issue');
},
supplier: function(doc) {
erpnext.utils.get_party_details(this.frm, null, null, null);
}
});

View File

@ -1197,7 +1197,7 @@
"columns": 0,
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Subcontract\"",
"fieldname": "supplier_address",
"fieldtype": "Small Text",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@ -1210,6 +1210,7 @@
"no_copy": 1,
"oldfieldname": "supplier_address",
"oldfieldtype": "Small Text",
"options": "Address",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@ -1221,6 +1222,35 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Address",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -1654,7 +1684,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-04-10 12:01:40.888115",
"modified": "2017-04-13 11:55:06.828073",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry",