[fix] remove duplicate newsletter subscribers
This commit is contained in:
parent
cba5a684cb
commit
e9b14e497b
@ -206,4 +206,5 @@ execute:frappe.db.set_value("Stock Settings", None, "automatically_set_serial_no
|
||||
execute:frappe.db.sql("""update `tabProject` set percent_complete=round(percent_complete, 2) where percent_complete is not null""")
|
||||
erpnext.patches.v6_0.fix_outstanding_amount
|
||||
erpnext.patches.v6_0.fix_planned_qty
|
||||
erpnext.patches.v6_0.multi_currency
|
||||
erpnext.patches.v6_0.multi_currency
|
||||
erpnext.patches.v6_2.remove_newsletter_duplicates
|
||||
|
1
erpnext/patches/v6_2/__init__.py
Normal file
1
erpnext/patches/v6_2/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
12
erpnext/patches/v6_2/remove_newsletter_duplicates.py
Normal file
12
erpnext/patches/v6_2/remove_newsletter_duplicates.py
Normal file
@ -0,0 +1,12 @@
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
duplicates = frappe.db.sql("""select newsletter_list, email, count(name)
|
||||
from `tabNewsletter List Subscriber`
|
||||
group by newsletter_list, email
|
||||
having count(name) > 1""")
|
||||
|
||||
# delete all duplicates except 1
|
||||
for newsletter_list, email, count in duplicates:
|
||||
frappe.db.sql("""delete from `tabNewsletter List Subscriber`
|
||||
where newsletter_list=%s and email=%s limit %s""", (newsletter_list, email, count-1))
|
Loading…
x
Reference in New Issue
Block a user