fix: address and contact filters for SCO and SCR (backport #42310) (#42312)

fix: address and contact filters for SCO and SCR (#42310)

(cherry picked from commit 7656220075)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot]
2024-07-13 15:59:46 +05:30
committed by GitHub
parent e250dcc7c8
commit cb64c73c9e
2 changed files with 25 additions and 0 deletions

View File

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

View File

@@ -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: {