From fc473d6a245b10760701d6b5a0142480287289a5 Mon Sep 17 00:00:00 2001 From: vama Date: Sat, 18 Sep 2021 13:21:45 +0530 Subject: [PATCH] fix: PO/PINV - Check if doctype has company_address field before setting the value (#27441) Co-authored-by: Vama Mehta (cherry picked from commit 666eaae6ce976c5d820b3b9f91d23a0ed28a263a) # Conflicts: # erpnext/public/js/controllers/transaction.js --- erpnext/public/js/controllers/transaction.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 0bec99e06fb..086f0912072 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -988,11 +988,31 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'].includes(this.frm.doctype)) { let is_drop_ship = me.frm.doc.items.some(item => item.delivered_by_supplier); +<<<<<<< HEAD if (!is_drop_ship) { erpnext.utils.get_shipping_address(this.frm, function() { set_party_account(set_pricing); }); } +======= + // Get default company billing address in Purchase Invoice, Order and Receipt + if (this.frm.doc.company && frappe.meta.get_docfield(this.frm.doctype, "billing_address")) { + 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 || ""}, + debounce: 2000, + callback: function(r) { + if (r.message) { + me.frm.set_value("billing_address", r.message); + } else { + if (frappe.meta.get_docfield(me.frm.doctype, 'company_address')) { + me.frm.set_value("company_address", ""); + } + } + } + }); + } +>>>>>>> 666eaae6ce (fix: PO/PINV - Check if doctype has company_address field before setting the value (#27441)) } else { set_party_account(set_pricing);