[patch] [fix] event for project, oppty, lead

This commit is contained in:
Anand Doshi 2013-06-10 15:38:01 +05:30
parent dec9a165ac
commit 670199b9c6
4 changed files with 10 additions and 7 deletions

View File

@ -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`

View File

@ -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:

View File

@ -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:

View File

@ -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)