2019-01-22 18:22:20 +05:30
|
|
|
from __future__ import unicode_literals
|
2015-09-17 17:46:37 +05:30
|
|
|
import frappe
|
|
|
|
|
|
|
|
def execute():
|
2016-06-28 11:17:02 +05:30
|
|
|
duplicates = frappe.db.sql("""select email_group, email, count(name)
|
|
|
|
from `tabEmail Group Member`
|
|
|
|
group by email_group, email
|
2015-09-17 17:46:37 +05:30
|
|
|
having count(name) > 1""")
|
|
|
|
|
|
|
|
# delete all duplicates except 1
|
2016-06-28 11:17:02 +05:30
|
|
|
for email_group, email, count in duplicates:
|
|
|
|
frappe.db.sql("""delete from `tabEmail Group Member`
|
|
|
|
where email_group=%s and email=%s limit %s""", (email_group, email, count-1))
|