From 670199b9c62180044b387a8b9a205986f19e53c3 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 10 Jun 2013 15:38:01 +0530 Subject: [PATCH] [patch] [fix] event for project, oppty, lead --- patches/june_2013/p04_fix_event_for_lead_oppty_project.py | 5 ++++- selling/doctype/lead/lead.py | 4 ++-- selling/doctype/opportunity/opportunity.py | 4 ++-- utilities/transaction_base.py | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/patches/june_2013/p04_fix_event_for_lead_oppty_project.py b/patches/june_2013/p04_fix_event_for_lead_oppty_project.py index 6929eedcdd..3f66d8bfbb 100644 --- a/patches/june_2013/p04_fix_event_for_lead_oppty_project.py +++ b/patches/june_2013/p04_fix_event_for_lead_oppty_project.py @@ -9,7 +9,10 @@ def execute(): 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): - webnotes.get_obj(dt, ref_name).add_calendar_event() + if dt in ["Lead", "Opportunity"]: + webnotes.get_obj(dt, ref_name).add_calendar_event(force=True) + else: + webnotes.get_obj(dt, ref_name).add_calendar_event() else: # remove events where ref doc doesn't exist webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent` diff --git a/selling/doctype/lead/lead.py b/selling/doctype/lead/lead.py index 0e27261a26..a54343a907 100644 --- a/selling/doctype/lead/lead.py +++ b/selling/doctype/lead/lead.py @@ -65,14 +65,14 @@ class DocType(SellingController): self.check_email_id_is_unique() self.add_calendar_event() - def add_calendar_event(self, opts=None): + def add_calendar_event(self, opts=None, force=False): super(DocType, self).add_calendar_event({ "owner": self.doc.lead_owner, "subject": ('Contact ' + cstr(self.doc.lead_name)), "description": ('Contact ' + cstr(self.doc.lead_name)) + \ (self.doc.contact_by and ('. By : ' + cstr(self.doc.contact_by)) or '') + \ (self.doc.remark and ('.To Discuss : ' + cstr(self.doc.remark)) or '') - }) + }, force) def check_email_id_is_unique(self): if self.doc.email_id: diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py index 0540ac9881..9fb061b228 100644 --- a/selling/doctype/opportunity/opportunity.py +++ b/selling/doctype/opportunity/opportunity.py @@ -93,7 +93,7 @@ class DocType(TransactionBase): self.add_calendar_event() - def add_calendar_event(self, opts=None): + def add_calendar_event(self, opts=None, force=False): if not opts: opts = webnotes._dict() @@ -116,7 +116,7 @@ class DocType(TransactionBase): if self.doc.to_discuss: opts.description += ' To Discuss : ' + cstr(self.doc.to_discuss) - super(DocType, self).add_calendar_event(opts) + super(DocType, self).add_calendar_event(opts, force) def set_last_contact_date(self): if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date: diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index 4c70eba2d7..f9af912737 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -269,9 +269,9 @@ class TransactionBase(DocListController): if not self.doc.posting_time: self.doc.posting_time = now_datetime().strftime('%H:%M:%S') - def add_calendar_event(self, opts): + def add_calendar_event(self, opts, force=False): if self.doc.contact_by != cstr(self._prev.contact_by) or \ - self.doc.contact_date != cstr(self._prev.contact_date): + self.doc.contact_date != cstr(self._prev.contact_date) or force: self.delete_events() self._add_calendar_event(opts)