mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-26 05:15:20 +00:00
[minor] moved the address_and_contact utils to frappe
This commit is contained in:
@@ -75,10 +75,16 @@ def delete_lead_addresses(company_name):
|
||||
"""Delete addresses to which leads are linked"""
|
||||
leads = frappe.get_all("Lead", filters={"company": company_name})
|
||||
leads = [ "'%s'"%row.get("name") for row in leads ]
|
||||
addresses = []
|
||||
if leads:
|
||||
frappe.db.sql("""delete from tabAddress where name not in (select parent
|
||||
from `tabDynamic Link` dl where dl.link_doctype<>'Lead' and
|
||||
dl.parenttype='Address')""", debug=True)
|
||||
addresses = frappe.db.sql_list("""select parent from `tabDynamic Link` where link_name
|
||||
in ({leads})""".format(leads=",".join(leads)), debug=True)
|
||||
addresses = ["'%s'"%addr for addr in addresses]
|
||||
|
||||
frappe.db.sql("""delete from tabAddress where name in ({addresses}) and
|
||||
name not in (select distinct dl1.parent from `tabDynamic Link` dl1
|
||||
inner join `tabDynamic Link` dl2 on dl1.parent=dl2.parent
|
||||
and dl1.link_doctype<>dl2.link_doctype)""".format(addresses=",".join(addresses)), debug=True)
|
||||
|
||||
frappe.db.sql("""delete from `tabDynamic Link` where link_doctype='Lead' and parenttype='Address'
|
||||
and link_name in ({leads})""".format(leads=",".join(leads)), debug=True)
|
||||
|
||||
@@ -7,11 +7,11 @@ frappe.ui.form.on('Sales Partner', {
|
||||
|
||||
if(frm.doc.__islocal){
|
||||
hide_field(['address_html', 'contact_html', 'address_contacts']);
|
||||
erpnext.utils.clear_address_and_contact(frm);
|
||||
frappe.geo.clear_address_and_contact(frm);
|
||||
}
|
||||
else{
|
||||
unhide_field(['address_html', 'contact_html', 'address_contacts']);
|
||||
erpnext.utils.render_address_and_contact(frm);
|
||||
frappe.geo.render_address_and_contact(frm);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cstr, filter_strip_join
|
||||
from frappe.website.website_generator import WebsiteGenerator
|
||||
from erpnext.utilities.address_and_contact import load_address_and_contact
|
||||
from frappe.geo.address_and_contact import load_address_and_contact
|
||||
|
||||
class SalesPartner(WebsiteGenerator):
|
||||
website = frappe._dict(
|
||||
|
||||
Reference in New Issue
Block a user