mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 03:01:22 +00:00
Delete events via query instead of delete_doc function, to save time
This commit is contained in:
@@ -22,16 +22,21 @@ class TransactionBase(StatusUpdater):
|
|||||||
self.posting_time = now_datetime().strftime('%H:%M:%S')
|
self.posting_time = now_datetime().strftime('%H:%M:%S')
|
||||||
|
|
||||||
def add_calendar_event(self, opts, force=False):
|
def add_calendar_event(self, opts, force=False):
|
||||||
if self.contact_by != cstr(self._prev.contact_by) or \
|
if cstr(self.contact_by) != cstr(self._prev.contact_by) or \
|
||||||
self.contact_date != cstr(self._prev.contact_date) or force:
|
cstr(self.contact_date) != cstr(self._prev.contact_date) or force:
|
||||||
|
|
||||||
self.delete_events()
|
self.delete_events()
|
||||||
self._add_calendar_event(opts)
|
self._add_calendar_event(opts)
|
||||||
|
|
||||||
def delete_events(self):
|
def delete_events(self):
|
||||||
frappe.delete_doc("Event", frappe.db.sql_list("""select name from `tabEvent`
|
events = frappe.db.sql_list("""select name from `tabEvent`
|
||||||
where ref_type=%s and ref_name=%s""", (self.doctype, self.name)),
|
where ref_type=%s and ref_name=%s""", (self.doctype, self.name))
|
||||||
ignore_permissions=True)
|
if events:
|
||||||
|
frappe.db.sql("delete from `tabEvent` where name in (%s)"
|
||||||
|
.format(", ".join(['%s']*len(events))), tuple(events))
|
||||||
|
|
||||||
|
frappe.db.sql("delete from `tabEvent Role` where parent in (%s)"
|
||||||
|
.format(", ".join(['%s']*len(events))), tuple(events))
|
||||||
|
|
||||||
def _add_calendar_event(self, opts):
|
def _add_calendar_event(self, opts):
|
||||||
opts = frappe._dict(opts)
|
opts = frappe._dict(opts)
|
||||||
|
|||||||
Reference in New Issue
Block a user