From c1ef503d98ec630356c0d4314d6aa28ed9ceed17 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 29 Jul 2011 13:01:54 +0530 Subject: [PATCH 1/4] Patch to transfer db_name to account_id in control panel --- patches/patch.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index 86fcff6290..9894d20249 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 332 +last_patch = 333 #------------------------------------------- @@ -1336,3 +1336,7 @@ def execute(patch_no): p.add_permission('Lease Agreement', 'Accounts Manager', 1, read = 1) elif patch_no == 332: sql("update `tabDocField` set permlevel=1, hidden = 1 where parent = 'Bulk Rename Tool' and fieldname = 'file_list'") + elif patch_no == 333: + cp = Document('Control Panel','Control Panel') + cp.account_id = str(webnotes.cookies['account_id']).split('=')[-1] + cp.save() \ No newline at end of file From 38d12235385b2930f148616193e41d3377810699 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 29 Jul 2011 13:13:46 +0530 Subject: [PATCH 2/4] Removed patch to modify account id in control panel. Will write script to update that --- patches/patch.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/patches/patch.py b/patches/patch.py index 9894d20249..b3dc6a333b 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 333 +last_patch = 332 #------------------------------------------- @@ -1335,8 +1335,4 @@ def execute(patch_no): p.add_permission('Lease Agreement', 'Accounts Manager', 0, read = 1, write=1,submit=1, cancel=1,amend=1) p.add_permission('Lease Agreement', 'Accounts Manager', 1, read = 1) elif patch_no == 332: - sql("update `tabDocField` set permlevel=1, hidden = 1 where parent = 'Bulk Rename Tool' and fieldname = 'file_list'") - elif patch_no == 333: - cp = Document('Control Panel','Control Panel') - cp.account_id = str(webnotes.cookies['account_id']).split('=')[-1] - cp.save() \ No newline at end of file + sql("update `tabDocField` set permlevel=1, hidden = 1 where parent = 'Bulk Rename Tool' and fieldname = 'file_list'") \ No newline at end of file From b61abff9cdfce86493b18196354afc736c0c2ff1 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 10 Aug 2011 11:58:05 +0530 Subject: [PATCH 3/4] Reload billing page patch --- patches/patch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/patches/patch.py b/patches/patch.py index 76019c0f6b..26372b063f 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 335 +last_patch = 336 #------------------------------------------- @@ -1354,4 +1354,6 @@ def execute(patch_no): reload_doc('knowledge_base', 'doctype', 'answer') elif patch_no == 335: for dt in ['Account', 'Cost Center', 'Territory', 'Item Group', 'Customer Group']: - sql("update `tabDocField` set fieldtype = 'Link', options = %s where fieldname = 'old_parent' and parent = %s", (dt, dt)) \ No newline at end of file + sql("update `tabDocField` set fieldtype = 'Link', options = %s where fieldname = 'old_parent' and parent = %s", (dt, dt)) + elif patch_no == 336: + reload_doc('server_tools','page','billing') \ No newline at end of file From aabf1748a28d137c89fd73f2e7f5801ddaabeb88 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 10 Aug 2011 13:27:25 +0530 Subject: [PATCH 4/4] Added patch to update account id value in description_html of item, which maps the image url to the description --- patches/patch.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/patches/patch.py b/patches/patch.py index 26372b063f..94e0f11b2e 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 336 +last_patch = 337 #------------------------------------------- @@ -1356,4 +1356,21 @@ def execute(patch_no): for dt in ['Account', 'Cost Center', 'Territory', 'Item Group', 'Customer Group']: sql("update `tabDocField` set fieldtype = 'Link', options = %s where fieldname = 'old_parent' and parent = %s", (dt, dt)) elif patch_no == 336: - reload_doc('server_tools','page','billing') \ No newline at end of file + reload_doc('server_tools','page','billing') + elif patch_no == 337: + item_list = webnotes.conn.sql("""SELECT name, description_html + FROM tabItem""") + if item_list: + for item, html in item_list: + if html and "getfile" in html and "acx" in html: + ac_id = webnotes.conn.sql("""SELECT value FROM `tabSingles` WHERE doctype='Control Panel' AND field='account_id'""") + sp_acx = html.split("acx=") + l_acx = len(sp_acx) + if l_acx > 1: + for i in range(l_acx-1): + sp_quot = sp_acx[i+1].split('"') + if len(sp_quot) > 1: sp_quot[0] = str(ac_id[0][0]) + sp_acx[i+1] = '"'.join(sp_quot) + html = "acx=".join(sp_acx) + webnotes.conn.sql("""UPDATE tabItem SET description_html=%s WHERE name=%s""", (html, item)) + \ No newline at end of file