[fix] [minor] take correct docname when creating contact/address from a previous document
diff --git a/controllers/js/contact_address_common.js b/controllers/js/contact_address_common.js
index 82dad0e..7589947 100644
--- a/controllers/js/contact_address_common.js
+++ b/controllers/js/contact_address_common.js
@@ -16,11 +16,14 @@
if(doc.__islocal) {
var last_route = wn.route_history.slice(-2, -1)[0];
if(last_route && last_route[0]==="Form") {
+ var doctype = last_route[1],
+ docname = last_route.slice(2).join("/");
+
if(["Customer", "Quotation", "Sales Order", "Sales Invoice", "Delivery Note",
"Installation Note", "Opportunity", "Customer Issue", "Maintenance Visit",
"Maintenance Schedule"]
- .indexOf(last_route[1])!==-1) {
- var refdoc = wn.model.get_doc(last_route[1], last_route[2]);
+ .indexOf(doctype)!==-1) {
+ var refdoc = wn.model.get_doc(doctype, docname);
if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Customer" : true) {
cur_frm.set_value("customer", refdoc.customer || refdoc.name);
@@ -30,16 +33,16 @@
}
}
if(["Supplier", "Supplier Quotation", "Purchase Order", "Purchase Invoice", "Purchase Receipt"]
- .indexOf(last_route[1])!==-1) {
- var refdoc = wn.model.get_doc(last_route[1], last_route[2]);
+ .indexOf(doctype)!==-1) {
+ var refdoc = wn.model.get_doc(doctype, docname);
cur_frm.set_value("supplier", refdoc.supplier || refdoc.name);
cur_frm.set_value("supplier_name", refdoc.supplier_name);
if(cur_frm.doc.doctype==="Address")
cur_frm.set_value("address_title", cur_frm.doc.supplier_name);
}
if(["Lead", "Quotation"]
- .indexOf(last_route[1])!==-1) {
- var refdoc = wn.model.get_doc(last_route[1], last_route[2]);
+ .indexOf(doctype)!==-1) {
+ var refdoc = wn.model.get_doc(doctype, docname);
if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Lead" : true) {
cur_frm.set_value("lead", refdoc.lead || refdoc.name);