[event] [lead, opportunity, project] [fix] create events

This commit is contained in:
Anand Doshi
2013-06-10 15:15:40 +05:30
parent b2dc1aeca9
commit e53a81dcea
7 changed files with 157 additions and 133 deletions

View File

@@ -0,0 +1,21 @@
import webnotes
def execute():
# delete orphaned Event User
webnotes.conn.sql("""delete from `tabEvent User`
where not exists(select name from `tabEvent` where `tabEvent`.name = `tabEvent User`.parent)""")
for dt in ["Lead", "Opportunity", "Project"]:
for ref_name in webnotes.conn.sql_list("""select ref_name
from `tabEvent` where ref_type=%s and ifnull(starts_on, '')='' """, dt):
if webnotes.conn.exists(dt, ref_name):
controller = webnotes.get_obj(dt, ref_name)
if dt == "Project":
controller.add_calendar_event()
else:
controller.delete_events()
controller._add_calendar_event()
else:
# remove events where ref doc doesn't exist
webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent`
where ref_type=%s and ref_name=%s""", (dt, ref_name)))

View File

@@ -254,4 +254,5 @@ patch_list = [
"patches.may_2013.p05_update_cancelled_gl_entries",
"patches.june_2013.p01_update_bom_exploded_items",
"execute:webnotes.delete_doc('DocType', 'System Console')",
"patches.june_2013.p04_fix_event_for_lead_oppty_project",
]