brotherton-erpnext/patches/september_2013/p01_update_communication.py

22 lines
831 B
Python
Raw Normal View History

2013-11-20 07:29:58 +00:00
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
2013-09-12 12:13:38 +00:00
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
2013-09-02 12:09:59 +00:00
import webnotes
def execute():
2013-09-12 12:13:38 +00:00
webnotes.reload_doc("core", "doctype", "communication")
webnotes.conn.sql("""update tabCommunication set communication_date = creation where
ifnull(communication_date, '')='' """)
2013-09-02 12:09:59 +00:00
for doctype in ("Contact", "Lead", "Job Applicant", "Supplier", "Customer", "Quotation", "Sales Person", "Support Ticket"):
2013-09-12 12:13:38 +00:00
try:
fieldname = doctype.replace(" ", '_').lower()
webnotes.conn.sql("""update tabCommunication
set parenttype=%s, parentfield='communications',
parent=`%s`
where ifnull(`%s`, '')!=''""" % ("%s", fieldname, fieldname), doctype)
except webnotes.SQLError, e:
2013-09-12 12:13:38 +00:00
if e.args[0] != 1054:
raise