From cfa432dbcae7c5bfec6ec8be83229211de9c639c Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Wed, 25 Dec 2024 18:14:10 +0530 Subject: [PATCH 1/3] fix: set/update billing address on change of company (cherry picked from commit 0adfebee85c58bf0585b259f28f803ad852af182) --- .../accounts/doctype/purchase_invoice/purchase_invoice.js | 8 ++++++++ erpnext/public/js/controllers/transaction.js | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index dd8758e68a31..4a96c3a84e1e 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -719,6 +719,14 @@ frappe.ui.form.on("Purchase Invoice", { if (response) frm.set_value("credit_to", response.message); }, }); + + frappe.call({ + method: "erpnext.setup.doctype.company.company.get_default_company_address", + args: { name: frm.doc.company }, + callback: (r) => { + frm.set_value("billing_address", r.message || ""); + }, + }); } }, }); diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 18cddd7f7a1c..4e573234bb16 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -959,7 +959,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe let is_drop_ship = me.frm.doc.items.some(item => item.delivered_by_supplier); if (!is_drop_ship) { - console.log('get_shipping_address'); erpnext.utils.get_shipping_address(this.frm, function() { set_party_account(set_pricing); }); From 98631eb266889a309961747ee3a2c583aa7c8a63 Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Fri, 27 Dec 2024 12:35:36 +0530 Subject: [PATCH 2/3] fix: move code from purchase invoice to buying controller (cherry picked from commit cb197fd01f9bd7535dc1dd0a5f8e259e03f13fd5) --- .../doctype/purchase_invoice/purchase_invoice.js | 8 -------- erpnext/public/js/controllers/buying.js | 12 ++++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 4a96c3a84e1e..dd8758e68a31 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -719,14 +719,6 @@ frappe.ui.form.on("Purchase Invoice", { if (response) frm.set_value("credit_to", response.message); }, }); - - frappe.call({ - method: "erpnext.setup.doctype.company.company.get_default_company_address", - args: { name: frm.doc.company }, - callback: (r) => { - frm.set_value("billing_address", r.message || ""); - }, - }); } }, }); diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index 202efe157f08..c2c86fca960f 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -145,6 +145,18 @@ erpnext.buying = { }); } + company(){ + if(this.frm.doc.doctype == "Material Request") return; + + frappe.call({ + method: "erpnext.setup.doctype.company.company.get_default_company_address", + args: { name: this.frm.doc.company, existing_address:this.frm.doc.billing_address }, + callback: (r) => { + this.frm.set_value("billing_address", r.message || ""); + }, + }); + } + supplier_address() { erpnext.utils.get_address_display(this.frm); erpnext.utils.set_taxes_from_address(this.frm, "supplier_address", "supplier_address", "supplier_address"); From e582ff862e09fdcf024f1df64fbd48945a90002f Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Fri, 27 Dec 2024 12:53:41 +0530 Subject: [PATCH 3/3] fix: use meta to check field instead of doctype (cherry picked from commit 187c74ae0928de27d91cd453fc11a97d4797fbba) --- erpnext/public/js/controllers/buying.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index c2c86fca960f..5a8b63f601f4 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -146,7 +146,7 @@ erpnext.buying = { } company(){ - if(this.frm.doc.doctype == "Material Request") return; + if(!frappe.meta.has_field(this.frm.doc.doctype, "billing_address")) return; frappe.call({ method: "erpnext.setup.doctype.company.company.get_default_company_address",