From deb816d30c5accaa8496c6e8f6f491e0a25aefc7 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 12 Dec 2011 12:41:36 +0530 Subject: [PATCH] Patch to remove duplicate entries created due to change in validation_logic in Table Mapper Detail for the following doctypes: * Delivery Note-Receivable Voucher * Purchase Order-Purchase Voucher * Sales Order-Receivable Voucher --- .../remove_duplicate_table_mapper_detail.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 erpnext/patches/remove_duplicate_table_mapper_detail.py diff --git a/erpnext/patches/remove_duplicate_table_mapper_detail.py b/erpnext/patches/remove_duplicate_table_mapper_detail.py new file mode 100644 index 00000000000..aaddd9943cf --- /dev/null +++ b/erpnext/patches/remove_duplicate_table_mapper_detail.py @@ -0,0 +1,22 @@ +""" + Removes duplicate entries created in +""" +import webnotes +def execute(): + res = webnotes.conn.sql("""\ + SELECT a.name + FROM + `tabTable Mapper Detail` a, + `tabTable Mapper Detail` b + WHERE + a.parent = b.parent AND + a.from_table = b.from_table AND + a.to_table = b.to_table AND + a.from_field = b.from_field AND + a.to_field = b.to_field AND + a.name < b.name""") + if res and len(res)>0: + name_string = ", ".join(["'" + str(r[0]) + "'" for r in res]) + res = webnotes.conn.sql("""\ + DELETE FROM `tabTable Mapper Detail` + WHERE name IN (%s)""" % name_string)