From fedc772058a3c36f1e86e2fd06f1b6aef2022f59 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 10 Oct 2012 15:54:46 +0530 Subject: [PATCH] fix cancelled gl entries :patch --- patches/october_2012/fix_cancelled_gl_entries.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 patches/october_2012/fix_cancelled_gl_entries.py diff --git a/patches/october_2012/fix_cancelled_gl_entries.py b/patches/october_2012/fix_cancelled_gl_entries.py new file mode 100644 index 0000000000..9d23619d93 --- /dev/null +++ b/patches/october_2012/fix_cancelled_gl_entries.py @@ -0,0 +1,16 @@ +def execute(): + import webnotes + entries = webnotes.conn.sql("""select voucher_type, voucher_no + from `tabGL Entry` group by voucher_type, voucher_no""", as_dict=1) + for entry in entries: + try: + docstatus = webnotes.conn.sql("""select docstatus from `tab%s` where name = %s + and docstatus=2""" % (entry['voucher_type'], "%s"), entry['voucher_no']) + is_cancelled = docstatus and 'Yes' or None + if is_cancelled: + webnotes.conn.sql("""update `tabGL Entry` set is_cancelled = 'Yes' + where voucher_type = %s and voucher_no = %s""", + (entry['voucher_type'], entry['voucher_no'])) + except Exception, e: + print entry + print e