patch: update item tax rate in json format

This commit is contained in:
Nabin Hait
2013-03-29 10:48:41 +05:30
19 changed files with 57 additions and 51 deletions

View File

@@ -0,0 +1,16 @@
import webnotes
def execute():
for f in webnotes.conn.sql("""select parent, fieldname
from tabDocField where options="attach_files:" """, as_dict=1):
if webnotes.conn.get_value("DocType", f.parent, "issingle"):
fname = webnotes.conn.get_value(f.parent, None, f.fieldname)
if fname:
if not (fname.startswith("http") or fname.startswith("files")):
webnotes.conn.set_value(f.parent, None, f.fieldname, "files/" + fname)
else:
webnotes.conn.sql("""update `tab%(parent)s`
set %(fieldname)s =
if(substr(%(fieldname)s,1,4)='http' or substr(%(fieldname)s,1,5)='files',
%(fieldname)s,
concat('files/', %(fieldname)s))""" % f)

View File

@@ -0,0 +1,19 @@
import webnotes
import json
def execute():
"""replace item_tax_rate stored as string with a json string"""
webnotes.conn.auto_commit_on_many_writes = 1
for dt in ["Quotation Item", "Sales Order Item", "Sales Invoice Item",
"Delivery Note Item", "Supplier Quotation Item", "Purchase Order Item",
"Purchase Invoice Item", "Purchase Receipt Item"]:
for d in webnotes.conn.sql("""select name, item_tax_rate from `tab%s`
where ifnull(item_tax_rate, '')!=''""" % (dt,), as_dict=1):
try:
json.loads(d["item_tax_rate"])
except ValueError, e:
webnotes.conn.sql("""update `tab%s` set item_tax_rate=%s
where name=%s""" % (dt, "%s", "%s"),
(json.dumps(eval(d["item_tax_rate"])), d["name"]))
webnotes.conn.auto_commit_on_many_writes = 0

View File

@@ -225,4 +225,6 @@ patch_list = [
"patches.march_2013.p09_unset_user_type_partner",
"patches.march_2013.p10_set_fiscal_year_for_stock",
"patches.march_2013.p10_update_against_expense_account",
"patches.march_2013.p11_update_attach_files",
"patches.march_2013.p12_set_item_tax_rate_in_json",
]