[fix] Clear addressed and contacts on a new form
diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js
index 7a4ea90..646dfbf 100644
--- a/erpnext/buying/doctype/supplier/supplier.js
+++ b/erpnext/buying/doctype/supplier/supplier.js
@@ -12,6 +12,7 @@
if(doc.__islocal){
hide_field(['address_html','contact_html']);
+ erpnext.utils.clear_address_and_contact(cur_frm);
}
else{
unhide_field(['address_html','contact_html']);
diff --git a/erpnext/crm/doctype/lead/lead.js b/erpnext/crm/doctype/lead/lead.js
index e9b07fe..1dc8eb2 100644
--- a/erpnext/crm/doctype/lead/lead.js
+++ b/erpnext/crm/doctype/lead/lead.js
@@ -37,6 +37,8 @@
if(!this.frm.doc.__islocal) {
erpnext.utils.render_address_and_contact(cur_frm);
+ } else {
+ erpnext.utils.clear_address_and_contact(cur_frm);
}
},
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 7f69202..c0549ba 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -100,6 +100,11 @@
$.extend(erpnext.utils, {
+ clear_address_and_contact: function(frm) {
+ $(frm.fields_dict['address_html'].wrapper).html("");
+ frm.fields_dict['contact_html'] && $(frm.fields_dict['contact_html'].wrapper).html("");
+ },
+
render_address_and_contact: function(frm) {
// render address
$(frm.fields_dict['address_html'].wrapper)
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index 42cc93a..4cd5cc7 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -14,6 +14,8 @@
if(!frm.doc.__islocal) {
erpnext.utils.render_address_and_contact(frm);
+ } else {
+ erpnext.utils.clear_address_and_contact(frm);
}
var grid = cur_frm.get_field("sales_team").grid;
diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.js b/erpnext/setup/doctype/sales_partner/sales_partner.js
index 5d84ac1..669cabf 100644
--- a/erpnext/setup/doctype/sales_partner/sales_partner.js
+++ b/erpnext/setup/doctype/sales_partner/sales_partner.js
@@ -5,6 +5,7 @@
if(doc.__islocal){
hide_field(['address_html', 'contact_html']);
+ erpnext.utils.clear_address_and_contact(cur_frm);
}
else{
unhide_field(['address_html', 'contact_html']);