From df8304f00b3184fa7bcafad6b31c4d2ce7c12d24 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 14 Oct 2011 19:05:08 +0530 Subject: [PATCH] acc bal repost patch moved in separate file --- erpnext/patches/repost_account_bal.py | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 erpnext/patches/repost_account_bal.py diff --git a/erpnext/patches/repost_account_bal.py b/erpnext/patches/repost_account_bal.py new file mode 100644 index 0000000000..34edc04af8 --- /dev/null +++ b/erpnext/patches/repost_account_bal.py @@ -0,0 +1,31 @@ + +def execute(): + import webnotes + sql = webnotes.conn.sql + from webnotes.model.code import get_obj + + # stop session + webnotes.conn.set_global('__session_status', 'stop') + webnotes.conn.set_global('__session_status_message', 'Patch is running in background. \nPlease wait until it completed...\n') + + webnotes.conn.commit() + webnotes.conn.begin() + + # repost + comp = sql("select name from tabCompany where docstatus!=2") + fy = sql("select name from `tabFiscal Year` order by year_start_date asc") + for c in comp: + prev_fy = '' + for f in fy: + fy_obj = get_obj('Fiscal Year', f[0]) + fy_obj.doc.past_year = prev_fy + fy_obj.doc.company = c[0] + fy_obj.doc.save() + fy_obj.repost() + prev_fy = f[0] + sql("commit") + sql("start transaction") + + # free session + webnotes.conn.set_global('__session_status', '') + webnotes.conn.set_global('__session_status_message', '')