diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js index c4eea3fda451..c6ee3a3e0e35 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js @@ -9,6 +9,7 @@ frappe.ui.form.on("Subcontracting Order", { setup: (frm) => { frm.get_field("items").grid.cannot_add_rows = true; frm.get_field("items").grid.only_sortable(); + frm.trigger("set_queries"); frm.set_indicator_formatter("item_code", (doc) => (doc.qty <= doc.received_qty ? "green" : "orange")); @@ -93,6 +94,17 @@ frappe.ui.form.on("Subcontracting Order", { }); }, + set_queries: (frm) => { + frm.set_query("contact_person", erpnext.queries.contact_query); + frm.set_query("supplier_address", erpnext.queries.address_query); + + frm.set_query("billing_address", erpnext.queries.company_address_query); + + frm.set_query("shipping_address", () => { + return erpnext.queries.company_address_query(frm.doc); + }); + }, + onload: (frm) => { if (!frm.doc.transaction_date) { frm.set_value("transaction_date", frappe.datetime.get_today()); @@ -116,6 +128,8 @@ frappe.ui.form.on("Subcontracting Order", { }, refresh: function (frm) { + frappe.dynamic_link = { doc: frm.doc, fieldname: "supplier", doctype: "Supplier" }; + if (frm.doc.docstatus == 1 && frm.has_perm("submit")) { if (frm.doc.status == "Closed") { frm.add_custom_button( diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js index b4a127702e0e..83113a223c23 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js @@ -28,6 +28,8 @@ frappe.ui.form.on("Subcontracting Receipt", { }, refresh: (frm) => { + frappe.dynamic_link = { doc: frm.doc, fieldname: "supplier", doctype: "Supplier" }; + if (frm.doc.docstatus === 1) { frm.add_custom_button( __("Stock Ledger"), @@ -165,6 +167,15 @@ frappe.ui.form.on("Subcontracting Receipt", { }; }); + frm.set_query("contact_person", erpnext.queries.contact_query); + frm.set_query("supplier_address", erpnext.queries.address_query); + + frm.set_query("billing_address", erpnext.queries.company_address_query); + + frm.set_query("shipping_address", () => { + return erpnext.queries.company_address_query(frm.doc); + }); + frm.set_query("rejected_warehouse", () => { return { filters: {