mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-06 15:00:27 +00:00
patch to fix deleted contact and addresses
This commit is contained in:
12
patches/december_2012/deleted_contact_address_patch.py
Normal file
12
patches/december_2012/deleted_contact_address_patch.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
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))
|
||||||
Reference in New Issue
Block a user