diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index 1afca307d94..8c0be8042ac 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -171,13 +171,15 @@ erpnext.buying = { shipping_address: this.frm.doc.shipping_address }, callback: (r) => { - this.frm.set_value("billing_address", r.message.primary_address || ""); + if (!this.frm.doc.billing_address) + this.frm.set_value("billing_address", r.message.primary_address || ""); - if (!frappe.meta.has_field(this.frm.doc.doctype, "shipping_address")) return; - this.frm.set_value( - "shipping_address", - r.message.shipping_address || this.frm.doc.shipping_address || "" - ); + if ( + !frappe.meta.has_field(this.frm.doc.doctype, "shipping_address") || + this.frm.doc.shipping_address + ) + return; + this.frm.set_value("shipping_address", r.message.shipping_address || ""); }, }); erpnext.utils.set_letter_head(this.frm) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index ae3b7404f7f..66c54ec6639 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1022,19 +1022,20 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } else { set_pricing(); } + }; - } - - if (frappe.meta.get_docfield(this.frm.doctype, "shipping_address") && - ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'].includes(this.frm.doctype)) { - let is_drop_ship = me.frm.doc.items.some(item => item.delivered_by_supplier); - - if (!is_drop_ship) { - erpnext.utils.get_shipping_address(this.frm, function() { - set_party_account(set_pricing); - }); - } + if ( + frappe.meta.get_docfield(this.frm.doctype, "shipping_address") && + ["Purchase Order", "Purchase Receipt", "Purchase Invoice"].includes(this.frm.doctype) && + !this.frm.doc.shipping_address + ) { + let is_drop_ship = me.frm.doc.items.some((item) => item.delivered_by_supplier); + if (!is_drop_ship) { + erpnext.utils.get_shipping_address(this.frm, function() { + set_party_account(set_pricing); + }); + } } else { set_party_account(set_pricing); }