mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 12:25:09 +00:00
fix: set default company address in Sales Doctype on change of company
(cherry picked from commit a31075692c)
This commit is contained in:
@@ -782,24 +782,6 @@ frappe.ui.form.on("Sales Invoice", {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// When multiple companies are set up. in case company name is changed set default company address
|
|
||||||
company: function (frm) {
|
|
||||||
if (frm.doc.company) {
|
|
||||||
frappe.call({
|
|
||||||
method: "erpnext.setup.doctype.company.company.get_default_company_address",
|
|
||||||
args: { name: frm.doc.company, existing_address: frm.doc.company_address || "" },
|
|
||||||
debounce: 2000,
|
|
||||||
callback: function (r) {
|
|
||||||
if (r.message) {
|
|
||||||
frm.set_value("company_address", r.message);
|
|
||||||
} else {
|
|
||||||
frm.set_value("company_address", "");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onload: function (frm) {
|
onload: function (frm) {
|
||||||
frm.redemption_conversion_factor = null;
|
frm.redemption_conversion_factor = null;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -111,6 +111,33 @@ erpnext.sales_common = {
|
|||||||
this.toggle_editable_price_list_rate();
|
this.toggle_editable_price_list_rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
company() {
|
||||||
|
super.company();
|
||||||
|
this.set_default_company_address();
|
||||||
|
}
|
||||||
|
|
||||||
|
set_default_company_address() {
|
||||||
|
if (!frappe.meta.has_field(this.frm.doc.doctype, "company_address")) return;
|
||||||
|
var me = this;
|
||||||
|
if (this.frm.doc.company) {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.setup.doctype.company.company.get_default_company_address",
|
||||||
|
args: {
|
||||||
|
name: this.frm.doc.company,
|
||||||
|
existing_address: this.frm.doc.company_address || "",
|
||||||
|
},
|
||||||
|
debounce: 2000,
|
||||||
|
callback: function (r) {
|
||||||
|
if (r.message) {
|
||||||
|
me.frm.set_value("company_address", r.message);
|
||||||
|
} else {
|
||||||
|
me.frm.set_value("company_address", "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
customer() {
|
customer() {
|
||||||
var me = this;
|
var me = this;
|
||||||
erpnext.utils.get_party_details(this.frm, null, null, function () {
|
erpnext.utils.get_party_details(this.frm, null, null, function () {
|
||||||
|
|||||||
@@ -164,27 +164,6 @@ frappe.ui.form.on("Sales Order", {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
// When multiple companies are set up. in case company name is changed set default company address
|
|
||||||
company: function (frm) {
|
|
||||||
if (frm.doc.company) {
|
|
||||||
frappe.call({
|
|
||||||
method: "erpnext.setup.doctype.company.company.get_default_company_address",
|
|
||||||
args: {
|
|
||||||
name: frm.doc.company,
|
|
||||||
existing_address: frm.doc.company_address || "",
|
|
||||||
},
|
|
||||||
debounce: 2000,
|
|
||||||
callback: function (r) {
|
|
||||||
if (r.message) {
|
|
||||||
frm.set_value("company_address", r.message);
|
|
||||||
} else {
|
|
||||||
frm.set_value("company_address", "");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onload: function (frm) {
|
onload: function (frm) {
|
||||||
if (!frm.doc.transaction_date) {
|
if (!frm.doc.transaction_date) {
|
||||||
frm.set_value("transaction_date", frappe.datetime.get_today());
|
frm.set_value("transaction_date", frappe.datetime.get_today());
|
||||||
|
|||||||
Reference in New Issue
Block a user