From 0adfebee85c58bf0585b259f28f803ad852af182 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 --- .../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 adf49c42d41d..b7c17221215d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -721,6 +721,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 281dfeef97e0..250f7c70c7a7 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -983,7 +983,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 cb197fd01f9bd7535dc1dd0a5f8e259e03f13fd5 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 --- .../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 b7c17221215d..adf49c42d41d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -721,14 +721,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 187c74ae0928de27d91cd453fc11a97d4797fbba 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 --- 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",