You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

23 line
1.1 KiB

  1. import frappe
  2. from frappe.utils.background_jobs import enqueue
  3. def execute():
  4. comm_records_count = frappe.db.count("Communication", {"comment_type": "Updated"})
  5. if comm_records_count > 100000:
  6. enqueue(method=move_data_from_communication_to_activity_log, queue='short', now=True)
  7. else:
  8. move_data_from_communication_to_activity_log()
  9. def move_data_from_communication_to_activity_log():
  10. frappe.reload_doc("core", "doctype", "communication")
  11. frappe.reload_doc("core", "doctype", "activity_log")
  12. frappe.db.sql("""insert into `tabActivity Log` (name, owner, modified, creation, status, communication_date,
  13. reference_doctype, reference_name, timeline_doctype, timeline_name, link_doctype, link_name, subject, content, user)
  14. select name, owner, modified, creation, status, communication_date,
  15. reference_doctype, reference_name, timeline_doctype, timeline_name, link_doctype, link_name, subject, content, user
  16. from `tabCommunication`
  17. where comment_type = 'Updated'""")
  18. frappe.db.sql("""delete from `tabCommunication` where comment_type = 'Updated'""")
  19. frappe.delete_doc("DocType", "Authentication Log")