fix: Correct company address not getting copied from Purchase Order to Invoice (#27217) (#27235)

* fix: Correct company adderess not getting copied from Purchase Order to Invoice

* fix: Linting issues

(cherry picked from commit fd467e6d32)

Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
Co-authored-by: Afshan <33727827+AfshanKhan@users.noreply.github.com>
This commit is contained in:
Frappe PR Bot
2021-08-31 20:11:21 +05:30
committed by GitHub
parent 1b338d678a
commit 1063d85569
2 changed files with 17 additions and 13 deletions

View File

@@ -846,21 +846,25 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
if (frappe.meta.get_docfield(this.frm.doctype, "shipping_address") &&
in_list(['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'], this.frm.doctype)) {
erpnext.utils.get_shipping_address(this.frm, function(){
erpnext.utils.get_shipping_address(this.frm, function() {
set_party_account(set_pricing);
});
// Get default company billing address in Purchase Invoice, Order and Receipt
frappe.call({
'method': 'frappe.contacts.doctype.address.address.get_default_address',
'args': {
'doctype': 'Company',
'name': this.frm.doc.company
},
'callback': function(r) {
me.frm.set_value('billing_address', r.message);
}
});
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 {
me.frm.set_value("company_address", "");
}
}
});
}
} else {
set_party_account(set_pricing);

View File

@@ -289,8 +289,8 @@ erpnext.utils.get_shipping_address = function(frm, callback) {
company: frm.doc.company,
address: frm.doc.shipping_address
},
callback: function(r){
if (r.message){
callback: function(r) {
if (r.message) {
frm.set_value("shipping_address", r.message[0]) //Address title or name
frm.set_value("shipping_address_display", r.message[1]) //Address to be displayed on the page
}