From aabf1748a28d137c89fd73f2e7f5801ddaabeb88 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 10 Aug 2011 13:27:25 +0530 Subject: [PATCH] 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 26372b063f9..94e0f11b2e1 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