Nabin Hait | df8304f | 2011-10-14 19:05:08 +0530 | [diff] [blame] | 1 | |
| 2 | def execute(): |
| 3 | import webnotes |
| 4 | sql = webnotes.conn.sql |
| 5 | from webnotes.model.code import get_obj |
| 6 | |
| 7 | # stop session |
| 8 | webnotes.conn.set_global('__session_status', 'stop') |
| 9 | webnotes.conn.set_global('__session_status_message', 'Patch is running in background. \nPlease wait until it completed...\n') |
| 10 | |
| 11 | webnotes.conn.commit() |
| 12 | webnotes.conn.begin() |
| 13 | |
| 14 | # repost |
| 15 | comp = sql("select name from tabCompany where docstatus!=2") |
| 16 | fy = sql("select name from `tabFiscal Year` order by year_start_date asc") |
| 17 | for c in comp: |
| 18 | prev_fy = '' |
| 19 | for f in fy: |
| 20 | fy_obj = get_obj('Fiscal Year', f[0]) |
| 21 | fy_obj.doc.past_year = prev_fy |
| 22 | fy_obj.doc.company = c[0] |
| 23 | fy_obj.doc.save() |
| 24 | fy_obj.repost() |
| 25 | prev_fy = f[0] |
| 26 | sql("commit") |
| 27 | sql("start transaction") |
| 28 | |
| 29 | # free session |
| 30 | webnotes.conn.set_global('__session_status', '') |
| 31 | webnotes.conn.set_global('__session_status_message', '') |