2013-11-20 07:29:58 +00:00
|
|
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
2013-08-05 09:29:54 +00:00
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
2012-12-21 15:27:03 +00:00
|
|
|
import webnotes
|
|
|
|
def execute():
|
|
|
|
"""finds references of deleted addresses and contacts and deletes these references"""
|
|
|
|
import webnotes.model
|
|
|
|
|
|
|
|
for dt in ["Address", "Contact"]:
|
|
|
|
link_fields = webnotes.model.get_link_fields(dt)
|
|
|
|
for parent, lf in link_fields:
|
|
|
|
webnotes.conn.sql("""update `tab%s` ref set `%s`=null
|
|
|
|
where ifnull(`%s`, '')!='' and not exists (
|
|
|
|
select * from `tab%s` where name=ref.`%s`)""" % \
|
|
|
|
(parent, lf, lf, dt, lf))
|