Skip to content

Commit

Permalink
fix: address and contact filters for SCO and SCR (#42310)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure authored Jul 13, 2024
1 parent 9cf92ea commit 7656220
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down Expand Up @@ -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());
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 7656220

Please sign in to comment.